return void 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 31 32 | #include <stdio.h> #include <stdlib.h> #include <string.h> void* allocMemory (void); int main (void) { char* s1 = allocMemory(); strcpy (s1, "Hello, World!!"); printf("%s\n", s1); free (s1); int* numPtr1 = allocMemory(); numPtr1[0] = 10; numPtr1[1] = 20; printf ("%d %d\n", numPtr1[0], numPtr1[1]); free (numPtr1); //free (pointer); return 0; } void* allocMemory (void) { void* pointer = malloc (100); return pointer; } | cs |
0 개의 댓글:
댓글 쓰기