OK, so I have a function that deals with strings, fixing them so that I can handle them easier. Here is the function:
the problem is, that it doesn't like the part where I truncate off the whitespace (or at least I try to, the method I am using is probably crap), it wont compile the second for loop, because
BTW, I am using Dev-C++ if that has anything to do with it.
So my question is, how would I do this? The reason I have to truncate the spaces is I am using getline, and have functions later on that count the length of the string...
Code:
string fix(string str)
{
int length = str.size();
for (int i = 0; i < length; ++i)
{
str[i] = tolower(str[i]);
}
for (int i = length; str[i] == " " || str[i]==0; --i)
{
str.erase(i);
}
return str;
}
Originally posted by Dev-C++
So my question is, how would I do this? The reason I have to truncate the spaces is I am using getline, and have functions later on that count the length of the string...
Comment