Advertisement
Felanpro

Some cin random stuff

Nov 3rd, 2015
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. // cin with strings
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main ()
  7. {
  8.   string mystr;
  9.   cout << "What's your name? ";
  10.   getline (cin, mystr);
  11.   cout << "Hello " << mystr << ".\n";
  12.   cout << "What is your favorite team? ";
  13.   getline (cin, mystr);
  14.   cout << "I like " << mystr << " too!\n";
  15.   return 0;
  16. }
  17.  What's your name? Homer Simpson
  18. Hello Homer Simpson.
  19. What is your favorite team? The Isotopes
  20. I like The Isotopes too!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement