I am trying to free a memory in the main which has been allocated in a sub-function. Is this possible and am i doing this in the right fashion.
The code sample is:
char* SubFunction()
{
char *ptr= NULL;
char **values;
ptr= (char *)calloc( 100, sizeof( char ) );
if(ptr== NULL)
return ("ERROR");
strcpy( ptr, values[0] );
return ptr;
}
Main()
{
char *temp= NULL;
temp = SubFunction();
free(temp);
}