Created
October 13, 2019 01:35
-
-
Save BMuscle/c695e67b17367eeb41ad0c1f7db66121 to your computer and use it in GitHub Desktop.
ポインタ説明4
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宣言 | |
| 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