[時間割:C言語]『はじめてのC言語完全入門』その6
2008/10/07 20:54 posted by kunkichi
火曜日は『C言語』です。ちょいご無沙汰でした(^^; がんばります。
入力プログラムの応用
- 定数はdefineを使う。
#define TEISU 400 - 行の最後までが有効になる。
- スペースを含んでもOK。
- 行をまたぐ場合は最後に¥を使う。
- サンプル:
#include <stdio.h>実行結果:
#define STR "word and space"
#define PARAGRAPH "This is test for paragraph.\
new line"
int main()
{
printf("%s\n" , STR);
printf("%s\n" , PARAGRAPH);
return 0;
}$ ./en
word and space
This is test for paragraph. new line
- 定数を置き換えるのはプリプロセッサの地点。gcc -E でプリプロセスだけ行うとよくわかる。
$ gcc -E sample.c
・・・
int main()
{
printf("%s\n" , "word and space");
printf("%s\n" , "This is test for paragraph. new line");
return 0;
}
ifを使った選択文
- 他言語とほとんど一緒。
- 代入「式」を条件に使う
if( a = 4 )はa=4;と同じ。
if(a)
やっと本の半分弱まで来ました。日々の努力が大事です。





コメント&トラックバック
トラックバックURL: