length = user_input.length(); Will save lenght of entire "Hello Everyone" istringstream(user_input) >> inputString; Will read only "Hello"
So you have 5 characters string which you think is 19 characters long. Do not store length, Do not believe what other functions returns. Calculate it in place