Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
c++ - SOS----------About cin
It's from the Accelerated C++ I am puzzled about the "cin",it's said that "it discards any whitespace characters in the standard input stream, then reads from the standard input into variable",but why it outputs "Samuel Beckett",not "Samuel" and pause for next input? Thank you! *^_^* ______________________________________________________________________ "What does the following program do if, when it asks you for input, you type two names (for example, Samuel Beckett)? Predict the behavior before running the program, then try it. #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; } " Apr 27 2007
Mike skrev:It's from the Accelerated C++ I am puzzled about the "cin",it's said that "it discards any whitespace characters in the standard input stream, then reads from the standard input into variable",but why it outputs "Samuel Beckett",not "Samuel" and pause for next input? Apr 27 2007
|