C
Charles
This is very strange. In the following program, If I type a one-word
name, it works fine. Now, if I type a two-word name, the program splits
the variable into two:
#include <iostream>
#include <string>
int main()
{
std::cout << "What is your name? ";
std::string name;
std::cin >> name;
std::cout << "Hello, " << name
<< std::endl << "And what is yours? ";
std::cin >> name;
std::cout << "Hello, " << name
<< "; nice to meet you too!" << std::endl;
return 0;
}
Do you know why?
Thanks.
name, it works fine. Now, if I type a two-word name, the program splits
the variable into two:
#include <iostream>
#include <string>
int main()
{
std::cout << "What is your name? ";
std::string name;
std::cin >> name;
std::cout << "Hello, " << name
<< std::endl << "And what is yours? ";
std::cin >> name;
std::cout << "Hello, " << name
<< "; nice to meet you too!" << std::endl;
return 0;
}
Do you know why?
Thanks.