I am trying to write code in which i want to pass pointer into function and return pointer from function
This is my test code
Code:
#include<stdio.h>
#include<stdlib.h>
int *foo( int *ptr )
{
int *qtr = malloc (sizeof(*qtr));
if (qtr == NULL)
{
printf("Memory not allocated.\n");
return 0;
}
qtr = ptr;
return qtr;
}
int main()
{
int *ptr = malloc (sizeof(*ptr));
if ( ptr == NULL )
{
printf("Memory not allocated.\n");
return 1;
}
ptr = foo ( ptr );
return 0;
}
I am trying figure out what happen when we pass pointer into function and return pointer from function by printing memory location value. I don't have any idea how to make furthrt progress