// string::length
#include <iostream>
#include <string>
int main ()
{
std::string str ("random text");
std::cout << "The size of str is " << str.length() << " bytes.\n";
return 0;
}
The size of str is 11 bytes.
This is the sample program that p007 gave you the reference to. Press the wheel in the top right hand corner.
If you want the letter count, excluding spaces use isalpha() http://www.cplusplus.com/reference/cctype/isalpha/ or isspace() http://www.cplusplus.com/reference/cctype/isspace/
isspace is probably more useful because it is more direct (maybe)
So, if you count the number of spaces in the string and subtract that number from the total string length then you have the answer. You have the program for the total length, and all you have to do is run through each character in the string, if it is a space (or character) you can calculate what you want.
Spaces are the best to use because there might be numbers.
one thing to be noted is that size of a char is one byte, so when you are calculating the size you are automatically calculating the number of characters (including the spaces)
Use std::getline() when you want to get a std::string from the user that includes spaces:
http://www.cplusplus.com/reference/string/basic_string/getline/