+ 4

how can we input string with space in c++ ?

28th Dec 2017, 7:13 PM
Riya Runjhun
5 Respostas
+ 5
cin.getline(variableName, maxsize); ex char name[40]; cin.getline(name,40);
28th Dec 2017, 7:25 PM
MR Programmer
MR Programmer - avatar
+ 4
The Standard Library provides an input function called ws, which consumes whitespace from an input stream. You can use it like this: std::string s; std::getline(std::cin >> std::ws, s);
28th Dec 2017, 7:25 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 1
@GAWEN STEASY....if we want to use each character of the element by its index ...e.g. string a; a[0]=d; can we do the same with that to...can you please give me a short code..
28th Dec 2017, 8:45 PM
Riya Runjhun
+ 1
Use [A-Z,a-z, ""]
29th Dec 2017, 3:38 AM
Prince Amit
Prince Amit - avatar
+ 1
@riya runjhun you can do this easily in python using each in sentence in for loop where as you can split the words in character as like array and use index zero for the same purpose
29th Dec 2017, 3:40 AM
Prince Amit
Prince Amit - avatar