Created
October 12, 2019 12:07
-
-
Save BMuscle/93e949d1b76928a49cd11ba53ee5957e to your computer and use it in GitHub Desktop.
ポインタ説明2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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