21.01.2015 Views

第7回(6/4)

第7回(6/4)

第7回(6/4)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

TORU WAKAHARA<br />

・ 構 造 体 へのポインタの 宣 言 構 造 体 にアクセスするにはポインタを 利 用 するのが 一 般 的<br />

な 方 法 である。 構 造 体 を 指 すポインタを 用 いて 構 造 体 のメンバにアクセスするときは,<br />

アロー 演 算 子 ( -> )を 使 用 する。<br />

例 . 構 造 体 を 指 すポインタの 扱 い 方 を 示 す。<br />

#include <br />

#include <br />

struct s_type {<br />

int i;<br />

char str[80];<br />

} s, *p;<br />

int main()<br />

{<br />

p = &s;<br />

s.i = 10;<br />

p->i = 15;<br />

strcpy(p->str, "I like structure");<br />

printf("%d %d %s\n", s.i, p->i, p->str);<br />

}<br />

return 0;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!