Hello Rob,
If you want to input string with spaces then either you have to use gets() or cin.getline() function..
Example 1:
#include %26lt;iostream.h%26gt;
int main(void)
{
const SIZE = 100;
char msg[SIZE];
cout%26lt;%26lt;"Enter a string."%26lt;%26lt;endl;
cin.getline(msg,SIZE);
cout%26lt;%26lt;"The sentence you entered was"%26lt;%26lt;endl;
cout%26lt;%26lt;msg%26lt;%26lt;endl;
return 0;
}
For more information, see the following links :
http://www.functionx.com/cpp/examples/fs...
http://www.cprogramming.com/tutorial/les...
http://www.opengroup.org/onlinepubs/0096...
.
.
How can I get an string with spaces in c++?
getch();
Reply:use the gets function
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment