-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi, I'm pretty new to c++ . I'm trying to work out why the following code
doesn't work.
I've just learned about cin.get() and written the following program to enter
a string and store it in an array.
When I run the program it asks for the first string and then prints it.
However, it doesn't ask for input for the second string, it simply prints
"Enter the second string", then "The second string is: ".
Why doesn't cin.get() ask for input the second time around?
Thanks alot for any help
Chris.
#include<iostream>
#include<string>
int main()
{
char bufferOne[50];
std::cout << "Enter the first string: ";
std::cin.get( bufferOne, 49 );
std::cout << "The first string is " << bufferOne << std::endl;
char bufferTwo[50];
std::cout << "Enter the second string: ";
std::cin.get( bufferTwo, 49 );
std::cout << "The second string is " << bufferTwo << std::endl;
return 0;
}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE/TncRrAxy75AP1L8RAneAAJ91c46HwkcLcCJfCk7+ybcOy0AcBA CdHrUc
X3eTqKmgH6XGCCfw7u5u/9g=
=JgsO
-----END PGP SIGNATURE-----