+ 3
Hi guys, how can I input string with spaces in c++
C++ / strings / input with spaces??
3 Answers
+ 2
You can use std::getline() from the string header.
http://www.cplusplus.com/reference/string/string/getline/
Note, there is also another getline() which is part of istream in the iostream header. They're not the same. (c_string)
http://www.cplusplus.com/reference/istream/istream/getline/
+ 3
Thanks guys
0
i dont know much about cpp but in c i do it with fgets() or gets() function and u can also use pointers there if u want to with dynamic memory allocation.
so if C has those tricks than ofcourse CPP will have too.
also there is a string class so that can help u as well i think.