You need to look into what methods std::string has available. One of them is length(). It will tell you how long the string is. Another is the [] operator which will give you the character at a given location. With these things, and assuming you have a bunch of numbers in the string a, you can write logic like this:
int alength = a.length();
for( int i = 0; i < alength; ++i )
{
char cvalue = a[i];
if( cvalue == ' ' )
continue;
}
Exactly what you do with the characters there, I can't tell you because the description of your problem is lacking. For example, what does "correct" for your problem mean?