Welcome
Welcome to the forums of AntiRTFM's Absolute N00b Spoonfeed C++ Tutorials!

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, <a href="/profile.php?mode=register">join our community today</a>!

What does these codes do, ?

Ask ALL your questions here

What does these codes do, ?

Postby krazidudette on Wed Jun 17, 2009 12:08 pm

What does these codes do,
char f ;
cin >> f ;
return 0; ?

Please explain like i am retarded ? :)

Thanks
User avatar
krazidudette
 
Posts: 5
Joined: Mon Jun 15, 2009 5:40 pm

Re: What does these codes do, ?

Postby antiRTFM on Wed Jun 17, 2009 5:05 pm

the video explains it.

- creates a char variable
- does some magic that makes the program wait for the user to type in a letter, then puts that letter into the char variable

sort of like a "Press any key to continue..." kind of functionality
User avatar
antiRTFM
Administrator
 
Posts: 462
Joined: Sun Apr 13, 2008 9:10 am

Re: What does these codes do, ?

Postby krazidudette on Wed Jun 17, 2009 7:57 pm

antiRTFM;
thanks for responding. i was following your video. in the beginning you use the code (i think)

cin.get();
return 0;

then in later videos, you mentioned that the
char f ; cin >> f ;

is better or necessary.

Why?

Pls explain. I may have missed something
User avatar
krazidudette
 
Posts: 5
Joined: Mon Jun 15, 2009 5:40 pm

Re: What does these codes do, ?

Postby zorro59 on Thu Jun 18, 2009 5:07 am

If you want to pause a program you can use sistem("PAUSE") or cin.get()...
You shotuldnt use cin. Cin gets imput from the user and enters it in a variable. I dont think that you should use cin for pause because you add lines to your program and when you have a bigger program it will be very easy to loose track...
zorro59
 
Posts: 77
Joined: Tue May 12, 2009 2:28 am

Re: What does these codes do, ?

Postby antiRTFM on Thu Jun 18, 2009 12:34 pm

@krazidudette: As explained in the vid, cin.get() doesnt work so well if you have other cin commands in your code. When we used to have only cin.get(), we used it. When we started using more cin in our code, we changed to char f; cin >> f;

@Zorro59: meh, those aren't issues to be worried about at all for 2 lines of code. Just add a // comment explaining what it does.

And on the contrary; i'd disrecommend system("pause") being that its for Windows only, which make it non-Standard C++ code.
User avatar
antiRTFM
Administrator
 
Posts: 462
Joined: Sun Apr 13, 2008 9:10 am

Re: What does these codes do, ?

Postby zorro59 on Mon Jun 22, 2009 12:46 pm

If ppl want help for linux lets say, I think that they are going to post here the os they are using, if they dont I assume that they use windows...
zorro59
 
Posts: 77
Joined: Tue May 12, 2009 2:28 am

Re: What does these codes do, ?

Postby antiRTFM on Mon Jun 22, 2009 6:32 pm

The point isn't so much the OSs people use. The point is adhering to the holy Standard :)
User avatar
antiRTFM
Administrator
 
Posts: 462
Joined: Sun Apr 13, 2008 9:10 am

Re: What does these codes do, ?

Postby Seato on Fri Jul 03, 2009 11:30 pm

Haha, that's a nice way of putting it. The "holy standard," I like it :D.
User avatar
Seato
 
Posts: 23
Joined: Thu May 21, 2009 5:55 pm

Re: What does these codes do, ?

Postby zorro59 on Sat Jul 04, 2009 8:36 am

The "holy standard"
LOL!!!
zorro59
 
Posts: 77
Joined: Tue May 12, 2009 2:28 am


Return to QA

Who is online

Users browsing this forum: No registered users and 0 guests