Here is what I've got for PSET4: Resize so far. I get a segfault with proper usage of the program (i.e ./resize n infile outfile), and I have no clue where it's coming from. Furthermore, is my approach to horizontal resizing correct? When writing the RGBTRIPLE "triple" to the new scanline, I simply write the triple "n" times (I used "scale" as the variable for "n") by passing in "scale" as the in the fwrite() function.
// Copies a BMP file
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "bmp.h"
int main(int argc, char *argv[])
{
// ensure proper usage
if (argc != 4)
{
fprintf(stderr, "Usage: ./resize n infile outfile\n");
return 1;
}
// remember filenames
char *infile = argv[1];
char *outfile = argv[2];
// if second element in argv[] array is not a number, return 1 to main()
if (!isdigit(argv[1]))
{
return 1;
}
int scale = atoi(argv[1]);
[EDIT: unrelated code removed for Honor Code compliance.]