Finding Number of Chars in String?
Hi
I've got the following, which is supposed to allow for finding the number of characters in a string, and return that amount +1:
Code:
int function(string databaseDays)
{
int numberOfDays = 1;
for (int i=0; i < databaseDays.length(); i++)
{
if(databaseDays.at(i) == ".")
{
numberOfDays++;
}
}
}
When I try to compile though, I get the error: "ISO C++ forbids comparison between pointer and integer" regarding my if statement.
My understanding of the string::at(pos) function is to return the char at pos, and since "." is a char, where is this comparison error coming from? I must be overlooking something obvious.
Thanks