Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. string messageVar;
  2. cout << "Type your message: ";
  3. getline(cin, messageVar);
  4.  
  5. string messageVar;
  6. cout << "Type your message: ";
  7. cin.ignore();
  8. getline(cin, messageVar);
  9.  
  10. std::cin.ignore();
  11.  
  12. std::cin.ignore(std::numeric_limits<std::streamsize>::max(), 'n');
  13.  
  14. int main(){
  15. .... example with file
  16. //input is a file
  17. if(input.is_open()){
  18. cin.ignore(1,'n'); //it ignores everything after new line
  19. cin.getline(buffer,255); // save it in buffer
  20. input<<buffer; //save it in input(it's a file)
  21. input.close();
  22. }
  23. }
  24.  
  25. main ()
  26. {
  27. std::string name;
  28.  
  29. std::cout << "Please, enter your full name: ";
  30. std::getline (std::cin,name);
  31. std::cout << "Hello, " << name << "!n";
  32.  
  33. return 0;
  34. }
  35.  
  36. getchar();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement