開発環境
- OS X Lion - Apple(OS)
- TextWrangler(Text Editor) (BBEditの無料、light版)
- 言語: C
- コンパイラ: UNIX ccコンパイラ (汎用UNIX)
『実践プログラミング 第3版』 (Steve Oualline (著)、 望月 康司 (監修) (翻訳)、 谷口 功 (翻訳)、 オライリー・ジャパン、1998年、ISBN978-4900900646) II部(単純なプログラミング)の14章(ファイル入出力)14.10(プログラミング実習)実習14-5を解いてみる。
実習14-5.
コード(TextWrangler)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
FILE *in_file;
FILE *out_file;
int ch;
in_file = fopen("sample.c","r");
if(in_file == NULL){
fprintf(stderr,"Cannot open sample.c\n");
exit(8);
}
out_file = fopen("out.txt","w");
if(out_file == NULL){
fprintf(stderr,"Cannot open out.txt\n");
exit(8);
}
while(1){
ch = fgetc(in_file);
if(ch == EOF){
break;
}
if((ch & 0x80) != 0){
continue;
}
fputc(ch,out_file);
}
return (0);
}
こんな感じでいいのかあ〜ビット演算の記憶があやしくなってきた。。
0 コメント:
コメントを投稿