title: CS50 pset3 i want to resize this image, code is working for some and not for others? Can anyone tell me whats the problem?
body: <p>i want to resize it by "n", it is working for some but not for others , i don't know why, it has no image specific code as per i know, it should work for every image</p>
  
  <pre><code>// Get multiplier
  int n = atoi(argv[1]);
  
  // read infile's BITMAPFILEHEADER
  BITMAPFILEHEADER bf,bfR;
  fread(&amp;bf, sizeof(BITMAPFILEHEADER), 1, inptr);
  bfR = bf;
  
  // read infile's BITMAPINFOHEADER
  BITMAPINFOHEADER bi,biR;
  fread(&amp;bi, sizeof(BITMAPINFOHEADER), 1, inptr);
  biR = bi;
  // ensure infile is (likely) a 24-bit uncompressed BMP 4.0
  if (bf.bfType != 0x4d42 || bf.bfOffBits != 54 || bi.biSize != 40 ||
      bi.biBitCount != 24 || bi.biCompression != 0)
  {
      fclose(outptr);
      fclose(inptr);
      fprintf(stderr, "Unsupported file format.\n");
      return 4;
  }
  
  // modify bitmapinfoheader for height an width
  biR.biWidth = bi.biWidth*n;
  biR.biHeight = bi.biHeight*n;
  
  // determine padding for scanlines
  int padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
  int outpadding = (4 - (biR.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
  
  // modify bisizeimage
  biR.biSizeImage = (((biR.biWidth*(sizeof(RGBTRIPLE)))+outpadding)*abs(biR.biHeight));
  
  // write outfile's BITMAPFILEHEADER
  fwrite(&amp;bfR, sizeof(BITMAPFILEHEADER), 1, outptr);
  
  // modify bfsize before writing it
  bfR.bfSize = (sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + sizeof(biR.biSizeImage));
  
  // write outfile's BITMAPINFOHEADER
  fwrite(&amp;biR, sizeof(BITMAPINFOHEADER), 1, outptr);
  
  
  // iterate over infile's scanlines
  for (int i = 0, biHeight = abs(bi.biHeight); i &lt; biHeight; i++)
  {
      for(int m = 0; m &lt; n; m++)
      {
          // iterate over pixels in scanline
          for (int j = 0; j &lt; bi.biWidth; j++)
          {
              // temporary storage
              RGBTRIPLE triple;
  
              // read RGB triple from infile
              fread(&amp;triple, sizeof(RGBTRIPLE), 1, inptr);
  
              // write RGB triple to outfile
              for (int k = 0; k &lt; n; k++)
              {
              fwrite(&amp;triple, sizeof(RGBTRIPLE), 1, outptr);
              }
  
          }
  
           // skip over padding, if any
          fseek(inptr, padding, SEEK_CUR);
  
          //go back to reprint the same line
         if(m != n-1)
          {
              fseek(inptr, -bi.biWidth * sizeof(RGBTRIPLE),SEEK_CUR);
          }   
  
  
  
          // then add it back (to demonstrate how)
          for (int k = 0; k &lt; padding; k++)
          {
              fputc(0x00, outptr);
          }
  </code></pre>
  
  <p>Can anyone provide me with identifying the problem?I tried to look online but couldn't find any solution.website says "It looks like your post is mostly code; please add some more details", what i'm supposed to write more......</p>