integer to char table problems

From: AA (AA_at_example.com)
Date: 09/25/04


Date: Sat, 25 Sep 2004 17:23:49 -0400

I am trying to print a table of what integer corresponds to what
character. Can someone please tell me what is wrong with this code?

#include <stdio.h>

int main()
{

   char line[9]; /* each word in the wordlist */
   char d;

   for (d=0; d<=255; d++)
     printf("int=%d\tchar=%c\n",d,d);
}

Thanks in advance!



Relevant Pages

  • Re: K&R exercise 1-18
    ... _without_ the string terminator and has MAXIMUM+1 array elements. ... char lineis in this context equivalent to char *line ... int main ... You lose one character by overwriting it with '\n'. ...
    (comp.lang.c)
  • Re: Write to file
    ... You can read the file one character at a time. ... compared to the current char. ... Once the (lgh - 1)th char ... void initnext(int *next, const char *id, int lgh) ...
    (comp.lang.c)
  • Re: Common misconceptions about C (C95)
    ... int main ... void f ... printf("\nThe character is lower case.\n"); ... plain char to them, but they take unsigned char values. ...
    (comp.lang.c)
  • Re: Write to file
    ... int main(int argc, char *argv) ... I intended you you use c here not read another character! ... You reuse the buffer. ...
    (comp.lang.c)
  • Re: Small Correction to K&R Exercise 1-22 Solution on CLC-Wiki
    ... My fix is now reflected at the above address. ... I don't think that overwriting the n-th character with a ... single char location by letting a set sign bit indicate that a line ... int main ...
    (comp.lang.c)