Trivial C question: iterating through chars
Walter B. Ligon III
walt at clemson.edu
Fri Apr 20 10:08:24 PDT 2001
--------
Chris,
I'm not sure if you are more interested in ASCII or in C programming.
My suggestion is you try "man ascii" which will give you a complete
listing. otherwise, printable ascii runs from 32 to 126 decimal:
char c;
for (c = 32; c < 127; c++)
printf("Ascii %d is %c\n", c, c);
or you could try:
int i;
for (i = 0; i < 10000; i++)
{
if (isprint(i))
printf("Ascii %d is %c\n", i, i);
}
which will give you all sorts of stuff that isn't ascii, but is technically
"printable" - I only tested to 10000, but there are probably more printables
above that. I suppose you could go to MAXINT.
Walt
--
Dr. Walter B. Ligon III
Associate Professor
ECE Department
Clemson University
More information about the Beowulf
mailing list