I'm trying to create a function which will evaluate whether or not the user's command line input is a letter. The function returns an integer, which should be zero if the string is all alphabet characters and will be more than zero if anything else is true. In the function there is a for loop.
My problem is that the for loop is not executing at all. The lines outside the for
loop will run and the ones inside the for loop will not.
Source code:
int eval(string k)
{
// for loop scans input string k for items
for(int i = 0; i > strlen(k); i++)
{
// do something
}
return evalstatus;
}
Anything I'm missing would be much appreciated.
strlen(k)
into another variable since you don't want it to get called every time you iterate over your loop, consider using:for (int i = 0, j = strlen(k); i > j; ++i)
instead.