//kk //In place of char *p="hai friends",*p1; if i declare as char p[]="hai friends"; char *p1; //then ??
On Thu, Jun 16, 2011 at 8:16 AM, DIPANKAR DUTTA <dutta.dipanka...@gmail.com>wrote: > It's ok.. > > char *p="hai friends"...not correct.... > > bcz you did allocate memory for that string but assiging poiter to the base > address.. from where gcc will get the bse address of that string when u r > not actually allocate memory for it? thus it generate SIGSEG signal and give > invalid memory address...ie. segmentation fault > use malloc or use > char p[]=".."; > > > > > > > On Thu, Jun 16, 2011 at 4:49 AM, DK <divyekap...@gmail.com> wrote: > >> Gives me a SEGFAULT on gcc. >> Probably due to undefined behaviour. >> >> -- >> DK >> >> http://twitter.com/divyekapoor >> http://www.divye.in >> >> -- >> 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/-/QVAjKMQiWvoJ. >> >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Thanks and Regards, > ------------------------------ > *DIPANKAR DUTTA* > Visiting Research Scholar > Dept of Computing, > Macquarie University, Sydney, Australia > ph.no-+61 2 98509079 ( Mon-Fri 10:15-7:00) Sydney time > email: dipankar.du...@mq.edu.au > > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.