cin

what is the function of get.cin
and how to use it?
If I'm not mistaken (and I could be)... cin.get() allows you to specify the maximum number of characters read, where cin reads one word, and getline reads the entire line...

1
2
3
4
char Crap[25]; //set max # of characters 
 cout << "Please type in up to 25 characters" << endl;
 cin.get(Crap,25);
 cout << ' ' << Crap;


I believe the purpose is to control the size your input field. I could be wrong.


1
2
3
cout << "Enter your full name please :";
cin >> Crap;
cout << Crap << endl;


The user could type George Washington
but Crap would return only George (first word)


1
2
3
cout << "Enter your full name please :";
getline(cin, Crap);
cout << Crap << endl;


would return everything you typed...

Hope that helps.
Topic archived. No new replies allowed.