I am not familiar with pointers.. So, Kindly help to get clear understanding of pointers...
in Main, i am Passing ptr ip to func...
In func, I am pointing it to "treat"..
After returning 4m Main, I am not getting "Value of treat" in Main..
I am getting only previous ip value.............
Moreover, Address of Ip in Main and st in func are Same..... But if i pass &ip to func, i am getting value of treat in Main......... Why i am not getting "value of treat" earlier and How i am getting aftr passing &?..
[ Might be silly Quesn.. I m not familiar with that]..
Code:
#include<stdio.h>
void func(char *st);
char *ip="I am Here Only Buddy";
char treat[]="Hello i am no more here!!";
int main()
{
func(ip);
printf("Result aftr func:%s",ip);
printf("Address of ip:%u",ip);
getchar();
return 0;
}
void func(char *st)
{
printf("Value here b4:%s",st);
printf("Address of st:%u",st);
st=treat;
printf("Value:%s",st);
//return st;
}