+ 3

Hi guys, how can I input string with spaces in c++

C++ / strings / input with spaces??

24th Jun 2020, 2:29 AM
Michel Azar
Michel Azar - avatar
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/
24th Jun 2020, 2:57 AM
ChaoticDawg
ChaoticDawg - avatar
+ 3
Thanks guys
24th Jun 2020, 5:37 AM
Michel Azar
Michel Azar - avatar
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.
24th Jun 2020, 2:53 AM
NIK
NIK - avatar