07/08/30 23:12:07
>>73
>>120 の訂正と使い方 (関数 pgm_info の返り値で成否を判定できるようにした)
int pgm_info(const char *filename, char *pformat, int *pwidth, int *pheight, int *pdepth){
FILE *fp;
char buf[3+1];
int width, height, depth, ret=0;
fp=comment_remove(filename);
if(fp!=NULL){
if(fscanf(fp, "%3s%d%d%d", buf, &width, &height, &depth)==4){
sprintf(pformat, "%s", buf),*pwidth=width,*pheight=height,*pdepth=depth,ret=1;
}
fclose(fp);
}
return ret;
}
int main(void){
char format[3+1];
int width, height, depth;
pgm_info("a.pgm", format, &width, &height, &depth);
printf("format : %s\nwidth : %d\nheight : %d\ndepth : %d\n", format, width, height, depth);
return 0;
}