Just started in on Allain's book and rather frustratingly ran into issues despite following the book to the letter. I'm trying to wrap my head around how getline works.
The following piece of code compiles and runs fine.
But on the other hand this code, while it appears to compile, does nothing. It doesn't even print "test". Note getline @ 11. What am I missing? ThanksCode:#include <iostream> #include <string> int main() { std::string user_first_name = "test"; std::cout << user_first_name << "\n"; return 0; }
Code was edited to reflect that Elkvis first suggestion still doesn't run on my end.Code:#include <iostream> #include <string> int main() { std::string user_first_name = "test"; std::getline( std::cin, user_first_name, '\n' ); std::cout << user_first_name << "\n"; return 0; }