#include <ctype.h>
#include <stdio.h>
#include <string.h>
int getpos (char c)
{
int pos;
const char * alphabet = "abcdefghijklmnopqrstuvwxyz";
const char * found;
c = tolower (c);
found = strchr (alphabet, c);
pos = found - alphabet;
if (!found)
pos = 0;
else if (pos == 26)
pos = 0;
else
pos++;
return pos;
}
int main ()
{
char tests[] = {'A', '%', 'a', 'z', 'M', 0};
char * c;
for (c = tests; *c; c++) {
printf ("%d\n", *c - 'a' + 1);
printf ("%d\n", getpos (*c));
}
return 0;
}