#include <stdio.h>
int main() {
int arr[3] = {10, 20, 30};
int *p = arr; //arr = &arr[0]
printf("%d\n", *p);
printf("%d\n", *(p + 1));
printf("%d\n", *(p + 2));
*(p + 1) = 15; // arr[1] = 15
printf("arr[0] = %d\n", arr[0]);
printf("arr[1] = %d\n", arr[1]);
printf("arr[2] = %d\n", arr[2]);
//포인터 배열
int a = 1, b = 2, c = 3;
int *ptr[3] = {&a, &b, &c};
ptr[0] = &a;
ptr[1] = &b;
ptr[2] = &c;
printf("ptr[0] = %d\n", *ptr[0]);
printf("ptr[1] = %d\n", *ptr[1]);
printf("ptr[2] = %d\n", *ptr[2]);
printf("----숙제----\n");
int arr1[3] = {3, 6, 9};
int *p1 = arr1;
*(p1 + 1) = 100; // 이 한 줄만 배열 값을 바꿉니다.
// 여기에 답을 적어보세요!
// arr1[0] = 3
// arr1[1] = 100
// arr1[2] = 9
printf("arr1[0] = %d\n", p1[0]);
printf("arr1[1] = %d\n", p1[1]);
printf("arr1[2] = %d\n", p1[2]);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: