//Searching for specific characters
while (!stats.eof())
{
stats.getline(counter,200);
for (int i=0; i<strlen(counter); i++)
{
if (isupper(counter[i]))
upper++;
if (islower(counter[i]))
lower++;
if (isdigit(counter[i]))
decimal++;
if (isspace(counter[i]))
blank++;
if (counter[i] == '.')
end++;
if (counter[i] == '!')
end++;
if (counter[i] == '?')
end++;
total++;
}
}
Hi guys, I just finished my assignment but I'm still confused about the strlen command.
Above is the section of code to search through a text file and check for specific characters.
I tried using the strlen command to get the total no. of characters but it doesn't work. Thus, I had to use total++.
However for
for (int i=0; i<strlen(counter); i++)
It does search through the whole file though.
When i tried using
total = strlen(counter)
The result is not what I want at all. Weird...
Can anyone point me in the right direction?
Thanks in advance =]