Hi Roberto, You're welcome, but read the other comments since they have important information, including programming practice and a better explanation to the reason of the crash you were getting.
Regards, Kayo ----- Original Message ---- From: Roberto <[EMAIL PROTECTED]> To: [email protected] Sent: Wednesday, April 11, 2007 5:07:09 PM Subject: [c-prog] Re: Segmentation fault in a simple function. --- In [email protected], Kayo Hisatomi <[EMAIL PROTECTED]> wrote: > > Hi Roberto, > > The problem is in this line in the main() function: > > char *s0 = " bye 1 "; > > You are not allocating memory for the string, but just for > the pointer. So, try this: > > char s0[] = " bye 1 "; > > And the program will work. > > Regards, > Kayo. > Yes, this was the problem! I was confused with the two rows above. To assign a string to an array is right, but doing the same to a pointer need a strcpy or sprintf with the pointer of an allocated memory area, as you said. Thanks a lot, I spent a week to search the problem in the function, but the problem was out of it. Now it works. To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>. Yahoo! Groups Links ____________________________________________________________________________________ Don't get soaked. Take a quick peak at the forecast with the Yahoo! Search weather shortcut. http://tools.search.yahoo.com/shortcuts/#loc_weather To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>. Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/c-prog/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/c-prog/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
