Posted By:
2 Jul, 2013 6:51 am PDT

Acceptance of a string from user in C++.

Among cin>> and gets() which is better to accept a string from the user?
Attachment:None


cin’ receives a string from the keyboard and it is terminated as soon as it encounters a space. Hence strings with two or more words can’t be received by ‘cin

       ‘gets()’ receives a string from the keyboard and it is terminated only when the enter key is hit. There is no limit to the string length.

Hence gets() is used while accepting a string from the user.

Was it useful?  




Please login to reply to this problem.