I'm having some issues with a char** with file input. I'm doing a project where we are manipulating PGM files. I'm trying to get the header from the file using a char** but all it does is return null. It will run through the code that I have get the dimensions and return them to the screen but when I try to print the header I just get (null)
as my output
//Creation of the char**
char **header=(char**)malloc(2*sizeof(char*));
//File input
FILE * fin;
fin=fopen(argv[1], "rb");
fscanf(fin, "%s", *header);
printf("%s", header[0]);
fclose(fin);
I'm not 100% sure if I'm creating header
right or not or if I'm printing header
right either. Any help would be much appreciated.