Skip to content

Instantly share code, notes, and snippets.

@hiroshiro
Created March 7, 2015 15:31
Show Gist options
  • Save hiroshiro/3b2e39d78a99fc075f92 to your computer and use it in GitHub Desktop.
Save hiroshiro/3b2e39d78a99fc075f92 to your computer and use it in GitHub Desktop.
Cポインタを銀行口座として例える
/*
C言語のポインタのツボとコツがゼッタイにわかる本
著者 石黒 尚久
発行所 秀和システム
p47
*/
#include <stdio.h>
int main(void)
{
int iMyKouza; //int型の変数を定義(口座の預貯金)
int *piKouzaNumMemo; //int型のポインタ変数を定義(口座番号のメモ)を定義
iMyKouza = 12000; //12000を代入(預金額:12,000円)
piKouzaNumMemo = &iMyKouza; //iMyKouzaのアドレスを代入(口座番号を口座番号メモに代入)
//ポインタ変数piKouzaNumMemoに格納されているアドレス(口座番号)を表示
printf("変数iMyKouzaのアドレス:%p\n", piKouzaNumMemo);
return 0;
}
/* 実行結果
変数iMyKouzaのアドレス:0x7fff5f72e608
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment