I am using a library API , to this API iam sending a pointer variable in below two way
char *ptr = NULL;
second way is
while using the first implementation i have allocated some local buffer in my lower level function in that library API and assigend as below
char *testimg = NULL;
testimg = malloc(sizeof(char) * 1024);
char data = "hdfdfd...."; /* This is of total size occupying 1024*/
here if i do ptr = testimg
and print ptr it gives proper result in that function , but if i go to upper level funcitons / to the source program this ptr shows me as null .
In second implementation if i change the statements as below
*ptr = testimg
This gives me correct results in all uppler layer and source file .
How is this successfull when compare to the first implementation failure ?
Thanks in advance