Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string messageVar;
- cout << "Type your message: ";
- getline(cin, messageVar);
- string messageVar;
- cout << "Type your message: ";
- cin.ignore();
- getline(cin, messageVar);
- std::cin.ignore();
- std::cin.ignore(std::numeric_limits<std::streamsize>::max(), 'n');
- int main(){
- .... example with file
- //input is a file
- if(input.is_open()){
- cin.ignore(1,'n'); //it ignores everything after new line
- cin.getline(buffer,255); // save it in buffer
- input<<buffer; //save it in input(it's a file)
- input.close();
- }
- }
- main ()
- {
- std::string name;
- std::cout << "Please, enter your full name: ";
- std::getline (std::cin,name);
- std::cout << "Hello, " << name << "!n";
- return 0;
- }
- getchar();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement