Hello to all progg. out there.
The sample prog. i have written is of which i am facing three doubts :
char *someFun1()
{
char temp[ ] = "string";
return temp;
}
char *someFun2()
{
char temp[ ] = {'s', 't','r','i','n','g'};
return temp;
}
int main()
{
puts(someFun1());
puts(someFun2());
}
I) Its gives the warning that The function returns the addr. of a local variable
Can anyone explain the logic behind this?
II) replacing the char temp[] = {'s', 't', 'r', 'i', 'n', 'g'}
with ptr char* temp = {'s', 't', 'r', 'i', 'n', 'g'}
makes the prog jump out.
What is the prob i am facing here?
III) What is the difference between char temp[] = {'s', 't', 'r', 'i', 'n', 'g'}
char temp[] = {"string"}
Thanks for your help in advance.
Eagerly waiting for your reply.