掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Fopenでファイルを開くには? (ID:60559)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
Blue様ありがとうございます。 どうも違う部分がエラーの原因のようです。 どんどんわからなくなりました。 #include "stdafx.h" #define ORIGBUFSIZ 1024 #define COMPBUFSIZ 1040 FILE *fin, *fout; unsigned long origsize, compsize; unsigned char origbuf[ORIGBUFSIZ]; unsigned char compbuf[COMPBUFSIZ]; void error(char *msg) { fprintf(stderr, "Error: %s\n", msg); exit(1); } void do_compress() { fout=fopen("C:test.gz","rb"); while (1) { origsize = fread(origbuf, 1, ORIGBUFSIZ, fin); if (origsize == 0) { fwrite(&origsize, sizeof origsize, 1, fout); printf("圧縮終了"); break; } compsize = COMPBUFSIZ; compress(compbuf, &compsize, origbuf, origsize); fwrite(&compsize, sizeof compsize, 1, fout); fwrite(compbuf, compsize, 1, fout); printf("圧縮中・・・"); } } void main() { if((fin = fopen("C:test.txt","r"))==NULL) { printf("fileopenError\n"); exit(1); } do_compress(); fclose(fin); fclose(fout); }
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.