#include main () { unsigned char x; int i, width, height, max; i = 0; /* P6 225 171 255 255 255 ...pixels... 1,80,P 2,53,5 3,10, 4,50,2 5,50,2 6,53,5 7,32, 8,49,1 9,55,7 10,49,1 11,10, 12,50,2 13,53,5 14,53,5 15,10, */ x = getchar() ; /* should be a %c=P */ if (x != 'P') { printf("not a P, %d %c\n",x,x); exit(0); } x = getchar() ; /* should be a %c=6 */ if (x != '6') { printf("not a 6, %d %c\n",x,x); exit(0); } x = getchar() ; /* should be a %c=\n */ if (x != 10) { printf("not a char(10)\n"); exit(0); } printf("P3\n"); width = 0; height = 0; x = 48; do { width = width*10 + (x-48); x = getchar() ; } while (x != ' ') ; x = 48; do { height = height*10 + (x-48); x = getchar() ; } while (x != 10) ; printf("%d %d\n",width,height); max = 0; x = 48; do { max = max*10 + (x-48); x = getchar() ; } while (x != 10) ; printf("%d\n",max); printf("# created by RPL's unraw.c\n\n"); for (i=1; i<=3*width*height; i++) { x = getchar() ; printf("%d ",x); if (i % (3*width) == 0) printf("\n"); } }