Trivial C question: iterating through chars

David Rolenc david_rolenc at cos.sticomet.com
Fri Apr 20 12:07:02 EDT 2001


#include <stdlib.h>

int main()
{
  int i;
  for(i=0;i<128;i++)
  {
    printf("Char %c\n",i);
  }
  return 0;
}

On Fri, 20 Apr 2001, you wrote:
> I'd like to view all the ASCII chars on my system.  I tried:
> 
> char ch = 'NUL';
> int i;
> 
> for ( i = 0; i < 500; i++)
> 	printf("Char: %c/n", ch + i");
> 
> 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++)
> 
> Thanks,
> Chris
> 
> _______________________________________________
> Beowulf mailing list, Beowulf at beowulf.org
> To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf
--
 
David Rolenc
Software Engineer
System Administrator
Software Technology Inc.
email: david_rolenc at cos.sticomet.com
 


_______________________________________________
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