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
1 Answer
+ 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`