i think this must have produced a warning......conversion from const char * to char*.......
On Tue, Aug 16, 2011 at 8:52 PM, Sanjay Rajpal <[email protected]>wrote: > This is becuase "Hello" is a constant string and constant strings get > stored in *Data Area, not in stack for the function you called. *Thats why > pointer to constant string will be returned and program will not produce any > error. > > > Sanjay Kumar > B.Tech Final Year > Department of Computer Engineering > National Institute of Technology Kurukshetra > Kurukshetra - 136119 > Haryana, India > > > > On Tue, Aug 16, 2011 at 8:19 AM, rohit <[email protected]> wrote: > >> #include<stdio.h>const char *fun(); >> int main() >> { >> char *ptr = fun(); >> return 0; >> }const char *fun() >> { >> return "Hello"; >> } >> >> >> Why doesn't this code give error?? >> >> -- >> 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/-/qeUTNwGNKfwJ. >> 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. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > 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. > -- Regards Himanshu Kansal Msc Comp. sc. (University of Delhi) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. 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.
