Skip to content

Instantly share code, notes, and snippets.

@BMuscle
Created October 12, 2019 12:07
Show Gist options
  • Select an option

  • Save BMuscle/93e949d1b76928a49cd11ba53ee5957e to your computer and use it in GitHub Desktop.

Select an option

Save BMuscle/93e949d1b76928a49cd11ba53ee5957e to your computer and use it in GitHub Desktop.
ポインタ説明2
#include <stdio.h>
int main()
{
int a[10]; //int型の配列10個分 a宣言
int b; //int型 b宣言
int *p; //int型ポインタp宣言
p = &b; //bのアドレスをpに格納
//forで0-9まで格納していく
for (int i = 0; i < 10; i++) {
a[i] = i;
p[i] = i;
}
//forで10個分出力
for (int i = 0; i < 10; i++) {
printf("a[]=%d *p=%d\n", a[i], p[i]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment