목록전체 글 (351)
printf("ho_tari\n");
#include int main(void) { int nums[] = {1, 2, 3, 4, 5}; int *p; p = nums; for (int i = 0; i < 5; ++i) { printf("%d ", nums[i]); } printf("\n"); for (int i = 0; i < 5; ++i) { printf("%d ", *(nums + i)); } printf("\n"); for (int i = 0; i < 5; ++i) { printf("%d ", *(p + i)); } printf("\n"); for (int i = 0; i < 5; ++i) { printf("%d ", p[i]); } printf("\n"); return 0; }
#include int main(void) { int nums[] = {1, 2, 3, 4, 5}; int *p; p = nums; // p = &nums[0]; printf("*p = %d\n", *p); ++p; // p = p + 1; printf("*p = %d\n", *p); p = nums; printf("*(p + 2) : %d\n", *(p + 2)); return 0; }
#include int main(void) { int i = 100; double d = 3.14; void *p; p = &i; //*p = 200; *(int *)p = 200; p = &d; //*p = 3.14; *(double *)p = 2.718; printf("i: %d\td: %f\n", i, d); return 0; }
#include int add(int a, int b) { return a + b; } int substract(int a, int b) { return a - b; } int main(void) { int (*fp)(int, int); fp = &add; int re = (*fp)(4, 3); printf("re: %d\n", re); fp = &substract; re = (*fp)(4, 3); printf("re: %d\n", re); return 0; }
#include int main(void) { int a; int *pa; int **ppa; a = 100; pa = &a; ppa = &pa; **ppa = 200; printf("a: %d\n", a); return 0; }
#include int main(void) { int a = 0x12345678; //int *p; char *p; p = (char*)&a; printf("*p : 0x%x\n", *p); return 0; }