開発環境
- OS X Lion - Apple(OS)
- TextWrangler(Text Editor) (BBEditの無料、light版)
- 言語: C
- コンパイラ: UNIX ccコンパイラ (汎用UNIX)
『実践プログラミング 第3版』 (Steve Oualline (著)、 望月 康司 (監修) (翻訳)、 谷口 功 (翻訳)、 オライリー・ジャパン、1998年、ISBN978-4900900646) II部(単純なプログラミング)の10章(Cプリプロセッサ)10.1(#define文)設問10-3を解いてみる。
設問10-3.
#define文の行端にセミコロン「;」があるから予期しない結果になる。
修正。
コード(TextWrangler)
#include <stdio.h>
#define SIZE 10
#define FUDGE SIZE -2
int main(){
int size = FUDGE;
printf("Size is %d\n", size);
return (0);
}
入出力結果(Terminal)
$ cc -g -o sample sample.c $ ./sample Size is 8 $
0 コメント:
コメントを投稿