I'm trying to write a function to count the number of alphanumeric character(a,b,c,d,..,z), in a string. My code looks like it doesn't have error..., but when I run it, function stops to count characters before the end of the string. Someone can find why is that? Thanks for your times.
int counter(char text[])
{
int length = strlen(text), counter = 0;
for (int i = 0; i < length; i++)
{
if (isalpha(text[i]))
{
counter++;
i++;
}
else i++;
}
return counter;
}