開発環境
- OS X Lion - Apple(OS)
- TextWrangler(Text Editor) (BBEditの無料、light版)
- 言語: C
- コンパイラ: UNIX ccコンパイラ (汎用UNIX)
『実践プログラミング 第3版』 (Steve Oualline (著)、 望月 康司 (監修) (翻訳)、 谷口 功 (翻訳)、 オライリー・ジャパン、1998年、ISBN978-4900900646) II部(単純なプログラミング)の12章(高度な型)12.9(プログラミング実習)実習12-1を解いてみる。
実習12-1.
コード(TextWrangler)
#include <stdio.h> struct mailing{ char name[60]; char address1[60]; char address2[60]; char city[40]; char state[2]; long int zip; }; void p(struct mailing mail); int main(){ struct mailing mail1 = { "kamimura", "abcde", "efghi", "jklmn", "op", 12345 }; p(mail1); return (0); } void p(struct mailing mail){ printf("name: %s\n", mail.name); printf("address1: %s\n", mail.address1); printf("address2: %s\n", mail.address2); printf("city: %s\n", mail.city); printf("state: %s\n", mail.state); printf("zip: %ld\n", mail.zip); }
入出力結果(Terminal)
$ cc -g -o sample sample.c $ ./sample name: kamimura address1: abcde address2: efghi city: jklmn state: op zip: 12345 $
0 コメント:
コメントを投稿