Counting spaces in a char array

When I put any sentence say "Hello my name is bob." When using the stdlen in a manner such as
1
2
3
4
cout << "Please insert sentence"; 
cin >> sentence;
nums[0] = strlen(sentence); 
//where sentence is a char array //  

it stops detecting after Hello. The reason being I am guessing after the 'o' there is a /0 signifying a void and thus the means to terminate the scan. So how does one count the character of the entire sentence including the spaces?
std::getline( std::cin, sentence );

provided that sentence has type std::string. Or

std::cin.getline( sentence, sizeof( sentence ) );

provided that sentence is a character array.
Last edited on
but how would I get num [0] = sizeof (sentence)? I intend to manipulate this number for other uses. Sorry if I mislead a bit.
The same way as you wrote.:)
I see thanks.
Topic archived. No new replies allowed.