C/C++の宿題を片付けます 95代目at TECH
C/C++の宿題を片付けます 95代目 - 暇つぶし2ch121:デフォルトの名無しさん
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;
}


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch