0

how to make c++ read my first input if input space as the first character?

example i input _123 // '_' symbol means space if i use strlen i want to get 4 not 3 because of the space

8th Dec 2018, 6:24 AM
arase
1 Odpowiedź
+ 3
A simple solution would be like this #include <iostream> #include <string> using namespace std; int main() { string s; cout << "Input is: "; getline (cin, s); cout << "Length of input is: " << s.length(); } Note: For C++ string, there's no need to use `strlen`
8th Dec 2018, 6:33 AM
Babak
Babak - avatar