Jump to content

Featured Replies

  • Replies 87
  • Views 711
  • Created
  • Last Reply

Top Posters In This Topic

  • Author
then wat site do u recommend? just remember...all tat i learnd for C++, i have read it on my own....i just read some tuts online n tried it out so i wont know a lot
  dark_urza said:
then wat site do u recommend? just remember...all tat i learnd for C++, i have read it on my own....i just read some tuts online n tried it out so i wont know a lot

 

i learned java by myself. besides, you probably take information/computer science course in grade 10 (course code TIK20 here in Ottawa), so youve probably didnt learn c++ JUST by yourself

 

just buy a fucking book, or better yet, go to java . you dont need to worry about stupid crap like pointers in c++ (pointers are primaryly neccessary for virus makers, and virus makers are fucking losers) this is a good one

 

C++:

http://www.amazon.com/exec/obidos/tg/detail/-/0072226803/qid=1108920774/sr=8-1/ref=pd_csp_1/002-9964741-5205623?v=glance&s=books&n=507846

 

Java:

http://www.amazon.com/exec/obidos/tg/detail/-/0072230738/qid=1108920774/sr=8-2/ref=pd_csp_2/002-9964741-5205623?v=glance&s=books&n=507846

In C++, if you do not return an integer in your main function, its implied that the program ran successful and therefore returns 0. This is only possible with the main fucntion. It is considered good practice to return 0 (or exit(0)) explicitly though.

 

As a side note, system("pause") is non-portable by assuming "pause" is a command on the target platform, and on some platforms system is a security risk. On Linux where you can set suid, allows the program to run as the owner of the executable instead of the person actually executing the program, a person could write their own program and trick the system into executing it.

 

As for cin.get() (and any input for that matter), you should always prompt the user rather than assuming they know what you want. Also cin.get() becomes useless if there is any input lingering around in the buffer from a previous cin command, so you should atleast flush the buffer prior.

 

In either case, using these two methods beyond production should be avoided except for a few instances (i.e. program that outputs a Licenses agreement in which case you'd probably want them to type agree). Having a dangling input complicates scripting, anyone serious about running a DOS program is probably going to run it from a dos console, and those that just execute it probably just want the side effect or don't know what the hell it does anyways.

  • Author
  imascatman said:
i learned java by myself. besides, you probably take information/computer science course in grade 10 (course code TIK20 here in Ottawa), so youve probably didnt learn c++ JUST by yourself

 

just buy a fucking book, or better yet, go to java . you dont need to worry about stupid crap like pointers in c++ (pointers are primaryly neccessary for virus makers, and virus makers are fucking losers) this is a good one

 

C++:

http://www.amazon.com/exec/obidos/tg/detail/-/0072226803/qid=1108920774/sr=8-1/ref=pd_csp_1/002-9964741-5205623?v=glance&s=books&n=507846

 

Java:

http://www.amazon.com/exec/obidos/tg/detail/-/0072230738/qid=1108920774/sr=8-2/ref=pd_csp_2/002-9964741-5205623?v=glance&s=books&n=507846

 

 

im grd 9, im 15 cuz my bday in january...n the only language that i learned in class is TURING...uve never heard of it cuz the language is for beginners

  • Author
  RogueP2 said:

As for cin.get() (and any input for that matter), you should always prompt the user rather than assuming they know what you want. Also cin.get() becomes useless if there is any input lingering around in the buffer from a previous cin command, so you should atleast flush the buffer prior

QUOTE]

 

yea so if its say

 

int x;

 

cout<<"blah blah blah?\n";

cin>> x;

cin.ignore(); //this one?

cin.get();

"cin >> x" is a very good example of what I'm talking about. When you type something like "1" and enter ('\n'), 1 goes into x, but since cin.get() doesn't ignore whitespaces, the newline gets taken from the buffer negating the wait.

 

While cin.ignore() will ignore the next thing in the buffer (newline in this case), it only ignores one char in the buffer and so cin.get() will get anything in the buffer, so if someone put "1 2 3 4 5 6 7\n" the wait will get negated. To flush the buffer you use cin.sync() which will empty the buffer completely.

  • Author
o ok...hopefully ill get to learn some C++ in school next year...just got my course selection sheet today...so much comp/tech courses n all of them sound the same to me...just in a different order
  • 2 weeks later...
Guest
This topic is now closed to further replies.