c retrieve char * array pointer and display array value via array pointer
#include <stdio.h> #include <stdlib.h> #include <uuid/uuid.h> void retrieveUuid(char *uuidValue); char ** array4(); void arrayPointer5(); int main() { arrayPointer5(); } void arrayPointer5() { char **p=array4(); for(int i=0;i<100;i++) { printf("i=%d,str=%s\n",i,*(p+i)); } } char ** array4() { static char* arr[100]; for(int i=0;i<100;i++) { arr[i]=(char*)malloc(40); retrieveUuid(arr[i]); } char **p; p=&arr; return p; } void retrieveUuid(char *uuidValue) { uuid_t newUUID; uuid_generate(newUUID); uuid_unparse(newUUID,uuidValue); }
* represent pointer and can be prefixed at any type directly
When retrieve array elements via array pointer ,just loop the *(p+i) to draw the value