HOME | DD | Gallery | Favourites | RSS

| lcarsos

lcarsos ♂️ [6073523] [2007-11-27 04:36:25 +0000 UTC] "pronounced LCARS OS" (United States)

# Statistics

Favourites: 259; Deviations: 126; Watchers: 30

Watching: 85; Pageviews: 14495; Comments Made: 685; Friends: 85

# Interests

Favorite movies: Star Trek IV: The Voyage Home
Favorite TV shows: NCIS, Mythbusters, Big Bang Theory, Full Metal Alchemist
Favorite bands / musical artists: Jonathan Coulton, Mika
Favorite books: I, Robot; The Name of the Wind; Across the Nightingale Floor
Favorite writers: Isaac Asimov, Brian Jacques, Patrick Rothfuss
Favorite games: Dragon Age
Favorite gaming platform: PC
Tools of the Trade: Royal Quiet Deluxe, Thinkpad T23, (and sometimes WACOM Graphire 4)
Other Interests: freeform fictional writing, computers, Star Trek, the future

# About me

I'm a geeky college student majoring in Computer Science. I like music, drama, writing, reading, and math (and of course, Star Trek). Yeah, it's an interesting problem to have.

# Comments

Comments: 189

overseer [2012-08-11 05:50:53 +0000 UTC]

Thank you for ing my work. Much appreciated.

👍: 0 ⏩: 1

lcarsos In reply to overseer [2012-08-13 05:49:18 +0000 UTC]

Yep, I hope you allow downloads of it someday!

👍: 0 ⏩: 0

thefirstfleet [2012-08-05 10:43:06 +0000 UTC]

Thank you for the devwatch!

👍: 0 ⏩: 0

Shaoxiong [2011-05-07 07:39:49 +0000 UTC]

hey ! i finished everything !! YAY thanks to all dA

👍: 0 ⏩: 1

lcarsos In reply to Shaoxiong [2011-05-09 17:13:42 +0000 UTC]

hurrah!

👍: 0 ⏩: 1

Shaoxiong In reply to lcarsos [2011-05-10 04:23:44 +0000 UTC]

lol, take a guess of what i got out of 100 .

👍: 0 ⏩: 1

lcarsos In reply to Shaoxiong [2011-05-10 18:25:20 +0000 UTC]

A full 100? *hopes*

👍: 0 ⏩: 1

Shaoxiong In reply to lcarsos [2011-05-11 09:33:03 +0000 UTC]

yeah how did u know =.= ....
lol
like seriouslY 100%
LIKE OMFG ! I GOT 100%
for my first program assignemnt i got 91% lol

👍: 0 ⏩: 1

lcarsos In reply to Shaoxiong [2011-05-12 22:17:51 +0000 UTC]

w00t!

👍: 0 ⏩: 0

dokutoku [2011-05-05 00:41:43 +0000 UTC]

👍: 0 ⏩: 0

Shaoxiong [2011-04-29 23:19:28 +0000 UTC]

hi, i have done it !

it reads the input txt files !!!! it workers and debugs fine .

here the code, my online teacher

int a = 0;
double x,y;
ifstream inputFile;

inputFile.open("SampleSet.txt");

cout <<"Reading SampleSet.txt...\n";

//loop for the error is the file is not found
if (!inputFile)
{
cout<<"! ! !ERROR OPENING THE FILE! ! !\n";
}
while (inputFile>>x>>y)
{
cout< a++;
}

cout<<"\nThe number of elements:\t"<

btw...that code is the same as ....how u would do it ur way right ?

👍: 0 ⏩: 1

lcarsos In reply to Shaoxiong [2011-05-01 05:48:39 +0000 UTC]

Yay! I knew you could get it to work for you.

So in this one, you aren't storing your variables anywhere permanently, you're just counting how many sets you have, right?

If that's so, that would be almost exactly how I would write it. My only problem is with the line double x,y;. You've declared that you're going to use those variables, but you've left the value stored in them to be whatever is in RAM, having a program that every time you execute does something different because you're using variables that still have their garbage values in them and you haven't initialized them to anything is supremely annoying (trust me, I've spent three hours staring at code and wondering how it would continuously manage to come up with different bad results) non-repeatable errors are the bane of any programmers existence.

I would write that line like:
double x=0, y=0;

That way if your program compiles but doesn't work right, it will always not work right in exactly the same way. And that makes it easy to track down which line of code is wrong.

Better than initializing to zero, is initializing variables to a number that absolutely will not happen if the program is used as intended. So a lot of the time I'll actually initialize variables to -1 so that if a bug sneaks into the code, it's immediately obvious that the variable hasn't been set correctly.

Last thought, if I may nit-pick. The if statement where you're checking that the file was opened correctly. if statements are not loops, they are conditionals, they do not come back and recheck themselves to see if they have become true. They evaluate and then branch to either true or false. So, your comment saying to loop for the error would be better commented as checking if there was an error opening the file.

👍: 0 ⏩: 1

Shaoxiong In reply to lcarsos [2011-05-01 07:06:52 +0000 UTC]

yeah thanks for the x=0 and y=0 advice man really helpful ... os yeah ...the problem with me is still that varibles are not storing....

because i work all my programs on the if statement to change options. say option 1 was to count the values...how will i display the table in option 3? ....i can show the table in option 1 ....but then at option 3 it wont let me
maybe my values are not stored ?

👍: 0 ⏩: 1

lcarsos In reply to Shaoxiong [2011-05-02 18:20:41 +0000 UTC]

So, you're printing a menu to the console and you want your users to choose what they want? something like:

cout << "Choose what you want to do:\n" <<
"0. Exit the program\n" <<
"1. Count the values\n" <<
"2. [do something]\n" <<
"3. Show table of values\n" <<
"Option: " << flush;
int userOption = 0;
cin >> userOption;

Right?

If that's what you want then you're going to have a while loop that will probably go forever. You'll print out that menu, read in userOption and then have a huge if statement to go through everything. It'll probably look like:
if(userOption == 0) {
break;
} else if(userOption == 1) {
// Count the values
} else if ...

And so on. If one part of the if reads in the data, and another part needs the data to be read in, you will have to check that the data has been read in.

Hope that helps! Also, ask any further questions in a note please! (It must be getting hard to read these with how squished they are getting)

👍: 0 ⏩: 1

Shaoxiong In reply to lcarsos [2011-05-03 07:24:03 +0000 UTC]

na man is all good

thanks heaps

👍: 0 ⏩: 0

Shaoxiong [2011-04-26 08:09:58 +0000 UTC]

help me with something please ...C++

Say i have a file with 2 sets of data ... (2 colums)
and i want to get those 2 columms of figures on to C++ ,so how to store the numbers from a txt files in to an 2D array with in C++..how would i do that ? ...

👍: 0 ⏩: 2

lcarsos In reply to Shaoxiong [2011-04-26 19:07:15 +0000 UTC]

My bad, do a find and replace on that. every istream should be ifstream. And then just because variable names can be confusing, if it helps call is (what I named the input file variable) inf👍: 0 ⏩: 1

Shaoxiong In reply to lcarsos [2011-04-27 11:50:46 +0000 UTC]

sorry for the BIG spams on ur page

ok ,, mmmmmmm for my txt file it looks like this
1 1
1 1
1 1
1 1
1 1

the 1s are just replacement of the acctual numbers.
Are the elements in this txt 5 ? (5 elements)

this is really embrassing ,could u play write a int main for a program that takes ^those^ txt...and puts it in a 2D array....[you don't have to]
and displaying the amount of elements ?

i'll show u my code

----------------------------------------------------------------------
const int elements = 5;
int number [elements];
int SampleSet [5][2];
int count;

ifstream inputFile;
inputFile.open ("SampleSet.txt");
cout <<"Reading SampleSet.txt...\n";

//loop for the error
if (!inputFile)
{
cout<<"Error opening file.\n";
}
for (count=0; count < elements; count ++)
inputFile >> number[count];

cout <<"The number of elements is "<
--------------------------------------------------------------------------
thats the basic of my assignment lol , after that i gotta do the equation for simple regression line (which i have completed parts of)

👍: 0 ⏩: 1

lcarsos In reply to Shaoxiong [2011-04-27 21:52:27 +0000 UTC]

I'm not going to be doing your homework for you, but I will give you some tips and snippets of code to get you off on the right foot.

Okay, maybe I'm not understanding what you want, but, why are you reading into the number array? You're only going to read in 5 things into your number array, and then you're outputing a number that you have defined as a constant.

If you want to read data into a 2D array, you have to have two for loops (you can actually do it with one, but it looks a lot messier), which makes sense: a 1D array takes one for loop, a 2D array should be done with 2.

Just as a general rule, you should put your sizes for arrays into constant integers so that you can refer back to them (so you don't accidentally overflow out of your array, because your operating system will typically crash your application for you if you try to step outside of your bounds). So you want to pick a maximum value that is high enough for you. Since you know that you only have 2 columns of data, 2 will make sense as a good maximum, but for the number of rows your professor probably said how many values there are, or how many values you should be able to support. For simplicity's sake I'll go with 10 data values (representing 10 trials of the experiment, or what ever it is needs linear regression). So you're going to have something like:
const int ROWS = 10;
const int COLS = 2;

This could be done on one line, just put a comma between your ROWS definition and your COLS. So, now that we know the dimensions of our array, declare and initialize it:
int sampleSet[ROWS][COLS] = {};

This will make your 2D array, and initialize every spot to 0. If you don't initialize your array will start with whatever number was in RAM before (as your computer boots it sends a charge through some sectors of RAM to make sure it's there, and various processes will allocate and deallocate RAM, so by the time your program gets the space each value has garbage in it), by initializing your array to 0 you eliminate any possibility of weird values creeping into your analysis.

Now, since you've made an array of a ig enough size to fit your data into it, you might not fill it completely, so you need a counting variable to count how many values in your array are actually useful to you (again, this prevents any weird data creeping into your analysis). So, I'll usually make a variable named count or some derivative thereof if it's a big enough project and I already have a variable named count. So,
int count = 0;

We've now got everything set up to read in the data (sorry, I'm a bit wordy, I try to make sure everything is well explained). So, you're going to use 2 nested for loops. The outer one will control which row you are altering, and the inner will control which column you're accessing.
for(count = 0; count < ROWS; count++) {
for(int col = 0; col < COLS; col++) {
inputFile >> sampleSet[count][col];
}
}

And that will read in a value into every spot of a 2D array (up until ROWS number of data values, in this case 10).

count will be the number of full data points read in, and you can use something like
for(int i = 0; i < ROWS; i++) { for(int j = 0; j < COLS; j++) { cout << sampleSet[i][j] << "\t"; } cout << endl; }

to prove that the file has been read in.

👍: 0 ⏩: 0

lcarsos In reply to Shaoxiong [2011-04-26 18:00:36 +0000 UTC]

Hi, I'm just curious, where did you hear about me? I don't think I've been posting too much about c++ here on dA.

Alright, and now the answer. Sorry, dA doesn't keep my spacing (I have it all indented right now, but when I preview it the indenting is gone), if you're getting confused copy and paste this into a text editor and indent everything between curly braces. I assume you've got the array set up, but just in case:
const int COLS = 2, ROWS = 3;
int array[ROWS][COLS] = 0;
istream is("data.txt"); //This opens that data file for reading, hope you knew that one.

From there you can go two ways. You can use getline() to read in the whole line into a string and do a lot of parsing to get it to go into your array, the parsing will look something like this:
int col = 0, row = 0;
//This snippet will go through a string until it finds a space, when it does
//everything up to that space will be put into the current cell, it replaces thisLine
//with a string that doesn't have that number in it, it then increments
//the column and lets the loop keep going until another space is found (this was written
//so you can change COLS and then have a 3 column array).
//When the loop exits there is still the last number left in the string so we have to assign
//that to the column and then the rest of the procedure can be followed (whether this is
//encapsulated in another for to read in multiple rows of data)
for(int i = 0; i < strlen(thisLine); i++) {
if(thisLine[i] == ' ') {
array[row][col++%COLS] = int(thisLine.substr(0,i+1));
thisLine = thisLine.substr(i+1);
}
}
array[row][col%COLS] = int(thisLine);

Or you could just read in each value into the array from the input. This method (no pun intended) assumes that your data file is uniform and doesn't have errors in its formatting.
int col = 0, row = 0;
//The argument will read in a whole line of the file as you described it
while(is >> array[row][col++%COLS] >> array[row++][col]) { // modulus COLS is just to make sure you don't segfault accidentally
col = 0;
//You can't (or at least, really shouldn't) assign values within the brackets for arrays
// So you have to enter your while to get everything set up for the next loop.
}

That way is the quicker and dirtier way. If you ever have to deal with real users (i.e. writing programs that won't be used just by you) you can't blindly expect users to have everything exactly formatted the way they say it is, or the exact way you expect it to. You have to give your users a little lee-way, and you have to fail gracefully. If your program crashes, then any malicious cracker can use your code as an entry point into the system. So while it works, it would be better if you just got into the habit of doing things the right way.

I hope that helps. I haven't checked to make sure everything compiles, but I've commented it enough that you should be able to get the gist of it. I've tried to be as helpful as possible, but I didn't want to do your homework for you, if anything is unclear, go ahead and write back and I'll try to clear it up.

👍: 0 ⏩: 1

Shaoxiong In reply to lcarsos [2011-04-27 09:59:53 +0000 UTC]

HOLY CRAP YOU WROTE ALL THAT FOR ME ?!?!?!?!
u are a legend.

have a llama

👍: 0 ⏩: 1

Shaoxiong In reply to Shaoxiong [2011-04-27 10:10:14 +0000 UTC]

btw im just opening the file using

ifstream inFile;
inFile.open ("SampleSet.txt");

=S ?

👍: 0 ⏩: 1

lcarsos In reply to Shaoxiong [2011-04-27 13:48:01 +0000 UTC]

You can open files that way, but it's easier (and slightly faster processor-wise) to use inFile's constructor rather than initializing and then using a member function to tell it what file it's reading.

👍: 0 ⏩: 0

Ponpoe [2010-09-25 06:25:50 +0000 UTC]

Oh hai thar~

👍: 0 ⏩: 1

lcarsos In reply to Ponpoe [2010-09-25 16:08:48 +0000 UTC]

Ohai.

👍: 0 ⏩: 1

Ponpoe In reply to lcarsos [2010-09-25 18:07:24 +0000 UTC]

I didn't know you had a DA account >w>

👍: 0 ⏩: 1

lcarsos In reply to Ponpoe [2010-09-26 01:26:15 +0000 UTC]

I didn't know what you're screen name was, but I figured you had an account. It just hadn't seemed to come up in the conversations that you and I have been in.

👍: 0 ⏩: 1

Ponpoe In reply to lcarsos [2010-09-26 01:47:44 +0000 UTC]

I see, I see o.o

👍: 0 ⏩: 0

Nami-Viveraldi [2010-08-16 17:16:51 +0000 UTC]

Thanks so much for the fav! 8D

👍: 0 ⏩: 1

lcarsos In reply to Nami-Viveraldi [2010-08-16 17:21:00 +0000 UTC]

It was well deserved. It was a very good read! Keep it up!

👍: 0 ⏩: 1

Nami-Viveraldi In reply to lcarsos [2010-08-16 17:33:54 +0000 UTC]

Thank you~ ^^ I will certainly try to keep writing these various stories. And, if you liked this one, I'd suggest reading my other ones...those, I feel, are better than this one! XD

👍: 0 ⏩: 0

Rosecrow13 [2010-02-16 01:24:32 +0000 UTC]

haha...you totally faved a picture... thanks, much!!

👍: 0 ⏩: 1

lcarsos In reply to Rosecrow13 [2010-02-18 03:14:09 +0000 UTC]

I have always loved your Cinderella logo (and it would have rocked the socks off of our posters if we had used it).

👍: 0 ⏩: 1

Rosecrow13 In reply to lcarsos [2010-02-18 03:31:12 +0000 UTC]

What we could have done, instead of using it for the poasters and such, would have been to have it as introductry(I know I spelled that wrong) art. As in, put it on a stand by where the cast photos were and have it as a little tid bit that people saw before they came in. And thanks,by the way, for being a great friend.

👍: 0 ⏩: 1

lcarsos In reply to Rosecrow13 [2010-02-18 05:27:43 +0000 UTC]

That would have been great! Why didn't we suggest that?

👍: 0 ⏩: 1

Rosecrow13 In reply to lcarsos [2010-02-18 06:09:48 +0000 UTC]

Because, we were wrapped in the spirit of Cinderella! And because if we were sure (which we weren't) that they would veto the sock idea, then we could have been doubly sure that they would have vetoed the entry art.

👍: 0 ⏩: 0

SorbetMystery [2009-12-06 00:24:12 +0000 UTC]

hi zeke!!!!!!!!! thnx 4 teh watch

👍: 0 ⏩: 1

lcarsos In reply to SorbetMystery [2009-12-08 02:49:13 +0000 UTC]

Always welcome sirrah.

👍: 0 ⏩: 1

SorbetMystery In reply to lcarsos [2009-12-09 04:16:12 +0000 UTC]

woot woot

👍: 0 ⏩: 0

XXlivetowriteXX [2009-11-27 06:12:06 +0000 UTC]

Well hi. I see you're writing some kind of story with my name in it, Julia. lol. I caught that as I was browsing through DA. Like, are you a writer?

👍: 0 ⏩: 1

lcarsos In reply to XXlivetowriteXX [2009-11-28 05:38:33 +0000 UTC]

Yes, I am a writer, because I can't draw to save my life, so I write.

Thanks for stopping by my profile and welcome to dA!

👍: 0 ⏩: 1

XXlivetowriteXX In reply to lcarsos [2009-11-28 06:54:49 +0000 UTC]

I can't draw either. And if it were the only thing to save my life, I'd fail miserably to. Us being writers, we're like two peas in a pod.
You're welcome and thanks. (:

~I live to write, not write to live <3

👍: 0 ⏩: 0

O-Jelly [2009-08-22 18:24:46 +0000 UTC]

Ooooh, YOU'RE the guy watching me :3 I didn't even notice!

Hmm... I can't find a Trekkie icon :/ that's sad. I would have spammed you with it

👍: 0 ⏩: 1

lcarsos In reply to O-Jelly [2009-08-22 19:13:04 +0000 UTC]

There you go Jelly.

I miss you! Come back sometimes, you guys left big shoes to fill!

👍: 0 ⏩: 1

O-Jelly In reply to lcarsos [2009-08-22 19:51:36 +0000 UTC]

ha!

Tell me when Access is, nobody's been able to do that thus far. I heard they canceled it O: I certainly hope not, for your sake.

👍: 0 ⏩: 1

lcarsos In reply to O-Jelly [2009-08-22 21:52:37 +0000 UTC]

Tuesdays and Thursdays 7:15-8:50 (except for weeks with holidays on friday). Kinda convoluted.

👍: 0 ⏩: 1

O-Jelly In reply to lcarsos [2009-08-23 03:48:32 +0000 UTC]

of course, the days that i go to school :/

I'll see what I can do once I'm comfortable driving without somebody in the car to yell at me when I try to go off the road...

👍: 0 ⏩: 1

lcarsos In reply to O-Jelly [2009-08-24 05:11:27 +0000 UTC]

lol, k, stay safe.

👍: 0 ⏩: 0

RalfMaximus [2009-08-22 05:24:27 +0000 UTC]

You had me at LCARS.

👍: 0 ⏩: 1

lcarsos In reply to RalfMaximus [2009-08-22 05:34:17 +0000 UTC]

Ossim Thanks for the watch! (And you get the distinction as first person on the Internet to get the joke before I had to explain it)

👍: 0 ⏩: 1


| Next =>