This code gives unpredictable result on execution because char a[] is auto
and will die when control goes out of fun()
#include<stdio.h>
char* fun()
{
char a[]="Hello";
return a;
}
int main()
{
char *b = fun();
printf("%s",b);
getch();
return 0;
}
But the same doesn't seem to be happening when simple integer variables are
passed from a function. That is, the are passed without any error. What
difference does an array make??
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/CXzmqwppomgJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.