I'm getting output as "pqrs"
, But my understanding was we cannot return local pointer. I'm started to think since char *t = "pqrs"
is string literal and it will be in read-only memory area, so we can return the local pointer — But not sure if my understanding is correct
#include <stdio.h>
#include <string.h>
char *t(char *s1)
{
char *t = "pqrs";
s1 = "fdsa";
return t;
}
int main()
{
char *s = "abcde";
s = t(s);
printf("%s \n",s);
return 0;
}