Trivial C question: iterating through chars

Per Jessen per at computer.org
Fri Apr 20 17:50:25 EDT 2001


On Fri, 20 Apr 2001 12:29:00 -0300, Chris Richard Adams wrote:

>I'd like to view all the ASCII chars on my system.  I tried:
>
>char ch = 'NUL';

char ch = 0;

>int i;
>for ( i = 0; i < 500; i++)
>	printf("Char: %c/n", ch + i");

One double-quote too many. Last one. And the /n should 
be a \n instead.

>
>This fails.
>
>1.) What is illegal here?
>
>2.) Can I use chars in my for look also...something like:
>
>for ( ch = 'NUL; i < 500; ch++, i++)

Yeah.
for ( ch = 0: ch < 256; ch++, printf("Char: %d = %c\n", ch, ch));


/Per, London

regards,
Per Jessen



_______________________________________________
Beowulf mailing list, Beowulf at beowulf.org
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf



More information about the Beowulf mailing list