I've been working on this pset for quite a few days now, but my program doesn't seem to be compiling. It keeps saying "could not create outfile"(my message). I have no idea what to do. Any help would be appreciated.
Btw, I got this error when I tried running ./resize 4 small.bmp large.bmp.
include
include
include
include "bmp.h"
int main(int argc, char *argv[]) { //Checks that three arguments are entered if (argc != 4) { printf("Enter three arguments\n"); return 1; }
//Checks that the first argument is an integer less than or equal to 100
if (atoi(argv[2]) >= 100)
{
printf("Integer must be less than or equal to 100\n");
return 2;
}
int n = atoi(argv[2]);
// Creates pointer for the file
char *infile = argv[3];
char *outfile = argv[4];
// Opens infile and stores it's address in inptr
FILE *inptr = fopen(infile, "r");
if (inptr == NULL)
{
printf("could not open infile, %s!\n", infile);
return 3;
}
//Opens outfile
FILE *outptr = fopen(outfile, "w");
if (outptr == NULL)
{
fclose(inptr);
printf("could not create outfile, %s!\n", outfile);
return 4;
}
// Read infoheader into inptr file
BITMAPINFOHEADER bi;
fread(&bi, sizeof(BITMAPINFOHEADER), 1, inptr);
BITMAPFILEHEADER bf;
fread(&bf, sizeof(BITMAPFILEHEADER), 1, outptr);