So I have a function that is used to copy over the header of a ppm file to another file and removes the comments. Is there a way to add onto this function so that I can pull out the width and height dimensions? The magic number is always P6 and the max color value is always 255.
Code:
void headerinfo(FILE * infile, FILE * outfile, int *wid, int *hei)
{
char line[100];
int c;
fgets(line, 100, infile);
c = strlen(line);
while (!
(4 <= c && line[c - 4] == '2' && line[c - 3] == '5'
&& line[c - 2] == '5' && line[c - 1] == '\n')) {
if (line[0] == '#') {
fgets(line, 100, infile);
c = strlen(line);
} else {
fputs(line, outfile);
fgets(line, 100, infile);
c = strlen(line);
}
}
fputs(line, outfile);
}