最近、『例解UNIX/Linuxプログラミング教室 システムコールを使いこなすための12講』を読んでいることもあって、(かなり)久しぶりに学生時代に教科書として使用したK&Rを読み返していたのですが、第5章の「5.12 複雑な宣言」の中に出てくる
- 宣言をことばによる記述に変換するプログラム
が面白そうでしたので実際に動作させてみました。
宣言をことばによる記述に変換するプログラム
実行結果
% gcc dcl.c getch.c -o dcl % ./dcl int a a: int int *pa pa: pointer to int int **pa pa: pointer to pointer to int int *daytab[13] daytab: array[13] of pointer to int int (*daytab)[13] daytab: pointer to array[13] of int void *comp() comp: function returning pointer to void void (*comp)() comp: pointer to function returning void char (*(*x())[])() x: function returning pointer to array[] of pointer to function returning char char (*(*x[3])())[5] x: array[3] of pointer to function returning pointer to array[5] of char
最後の2つは難しいですね。