A simple solution
int i; for(i = 0; i < 52; i++){ char ch = i + (i < 26? 'A' : 'a'); }
although I prefer, especially in sensible languages ββthat allow nested functions,
for(ch = 'A'; ch <= 'Z'; ch++) dosomething(ch); for(ch = 'a'; ch <= 'z'; ch++) dosomething(ch);
PS Kobe, I see in one of your comments that your reason for loops is to check if a character is a letter ... but a loop is a terrible way to do this. You can just do
if(('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')){ }
or, which is much better
#include ctype.h ... if(isalpha((unsigned char)c)){ }
(To understand why this is necessary, read the isalpha man page and the C language standard. This is one of several disgusting aspects of C.)
Jim balter
source share