I am trying to get started on this problem set. The walkthrough says that the first step in copy.c is to find the code that opens the clue.

That I see to be already done with this code:

  // remember filenames
char *infile = argv[1];
char *outfile = argv[2];

// open input file 
FILE *inptr = fopen(infile, "r");
if (inptr == NULL)
    fprintf(stderr, "Could not open %s.\n", infile);
    return 2;

// open output file
FILE *outptr = fopen(outfile, "w");
if (outptr == NULL)
    fprintf(stderr, "Could not create %s.\n", outfile);
    return 3;

The next step is to "update the header's info file for outfile. I assume that is this part of the code?

   // write outfile's BITMAPFILEHEADER
  fwrite(&bf, sizeof(BITMAPFILEHEADER), 1, outptr);

// write outfile's BITMAPINFOHEADER
fwrite(&bi, sizeof(BITMAPINFOHEADER), 1, outptr);

Is this where I should be starting? I should look how to change this header?


In Zamyla Chan's walkthrough of the 2017 whodunit, she lists the TODOs as follows:

  • open file

  • update header's info file

  • read clue's scanline, pixel by pixel

  • change pixel's color as necessary

  • write verdict's scanline, pixel by pixel

The first part of code you provided opens two files, inptr and outptr, and then checks to make sure that neither file is NULL. In this case, the clue.bmp will be the inptr and verdict.bmp will be outptr.

The second part of code your provided writes the BITMAPFILEHEADER and the BITMAPINFOHEADER to the outptr file. I believe this is already provided in copy.c.

This is a great start! Make sure, however, that you do everything listed above in the TODOs. Also make sure to watch Zamyla Chan's video - it is very useful when solving this problem set!

If you still have issues/questions, comment below.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .