FILE *fp;
fp = fopen(filen, "wb");
const char tok[2] = ",";
char str[340];
while (fgets(str, 340, stdin) != NULL)
{
struct test loadTest;
printf("You entered: %s", str);
strncpy(loadTest.level, strtok(str, tok), 20);
strncpy(loadTest.first, strtok(NULL, tok), 30);
fwrite(&loadTest, sizeof(struct test), 1, fp);
}
fclose(fp);
Hello all,
For some reason I'm getting a segmentation fault error in my code.
I'm almost positive the error is somewhere within the small code block above (since that's all I modified for the seg fault), but I can't seem to pinpoint it.
I know segmentation faults have to do with accessing memory I shouldn't be accessing, but I'm not sure where I am even doing that in the code.
Any help would be greatly appreciated!