I'm receiving a segfault when reading the first byte (and probably would on the following) of buffer which is a malloced array -- or perhaps not, if unsigned char *
doesn't mean what I think it does. Either way, this should be the relevant code;
char * name();
and FILE* outptr = NULL;
is declared above main, globally. BLOCK
and infile
is #defined as 512
and "card.raw"
respectively.
The rest of int main(void)
is below.
// Open input file, plus error check
FILE* inptr = fopen(infile, "r");
if (inptr == NULL)
{
printf("Could not open %s.\n", infile);
return 3;
}
// Allocate memory for one BLOCK and read from infile
unsigned char * buffer = malloc(BLOCK);
if (buffer == NULL)
return 3;
while (fread(&buffer, BLOCK, 1, inptr) != 0) {
*/ REMAINDER OF CODE REDACTED TO COMPLY WITH ACADEMIC HONESTY OF /*
}
Thanks!