How can I use an index variable for a recursive function that increments every time the function is called so it can return a value without passing it as a parameter or using static or global variables as I want to call this function more than one time not only once.
Here's my code:
bool isAlphabetic(string s)
{
static int i = 0;
if (i==s.size())
{
return true;
}
else if (!isalpha(s[i])){
return false;
}
i++;
return isAlphabetic(s);
}
Does any body know how to fix this? I know i'm using a static variable but this makes the function run correctly the first time its called but not after that.