Skip to content

Instantly share code, notes, and snippets.

@BMuscle
Created October 13, 2019 01:35
Show Gist options
  • Select an option

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

Select an option

Save BMuscle/c695e67b17367eeb41ad0c1f7db66121 to your computer and use it in GitHub Desktop.
ポインタ説明4
#include <stdio.h>
int main()
{
int a[10]; //int型の配列10個分 a宣言
char* p; //char型ポインタp宣言
p = (char*)a; //a[0]のアドレスを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