#include #include #include "project.h" int main(int argc, char **argv) { int n,m; int smelly; char c; int i,j; int *image; //parse the input if (!(getchar() == 'P' && getchar() == '5')) { //pgm files start with "P5" fprintf(stderr,"Need pgm data from stdin\n"); return(EXIT_FAILURE); } NEXTLINE(); while ((c = getchar()) == '#') NEXTLINE(); //ignore comments ungetc(c,stdin); scanf("%i%i%i",&n,&m,&smelly); //parse the important numbers NEXTLINE(); fprintf(stderr,"%ix%i image read. %i - should be 255 :-)\n",n,m,smelly); //prepare the Row-major Format 2-D array image = (int *)malloc(sizeof(int)*n*m); //fill up the input array using the pgm picture for (j=0; j