double pointer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include <stdio.h> #include <stdlib.h> int main(void) { int** doublePointer = calloc (3, sizeof (int *)); // dynamic allocation, vertical unsigned int loop = 0; for (loop = 0; loop < 3; loop++) { doublePointer[loop] = calloc (4, sizeof (int)); //dynamic allocation, horizon } doublePointer[0][0] = 10; doublePointer[2][0] = 20; doublePointer[2][3] = 30; printf("%d\n", doublePointer[0][0]); printf("%d\n", doublePointer[2][0]); printf("%d\n", doublePointer[2][3]); for (loop = 0; loop < 3; loop++) { free(doublePointer[loop]); // clear dynamic allocation, horizon } free (doublePointer); // clear dynamic allocation, vertical return 0; } | cs |
0 개의 댓글:
댓글 쓰기