If you really want to print the buffer array outside the local scope the declare it using a static specifier.. eg...'
#include<stdio.h> char *modify (char *s) { #define MAX 15 static char buffer[MAX]; strcpy (buffer, s); buffer[0] = 'H'; return buffer; } int main () { printf ("hello!!!\n\n"); printf ("%s ", modify ("hello!!!..")); getch(); } then you will get the desired output .. although I would not recommend such method... use call by reference instead. Pratyush Tewari On Tue, Jan 6, 2009 at 1:47 PM, daizi sheng <daizish...@gmail.com> wrote: > > there is no expected output of this program because it is obviously > implement dependent. if you really want to know the results, try to > run it. if you want to know why, dump the assemble code to check it > manually. > > anyway, I do not think this topic is related to this group. > > > > On Tue, Jan 6, 2009 at 5:18 AM, tania hamid <tan3...@gmail.com> wrote: >> >> >> Plz indicate the output of the following code and explain why is it so.. >> >> >> char *modify (char *s) >> { >> #define MAX 15 >> char buffer[MAX]; >> strcpy (buffer, s); >> >> buffer[0] = 'H'; >> return buffer; >> } >> >> int >> main () >> { >> printf ("hello!!!"); >> printf ("%s ", modify ("hello!!!")); >> } >> >> > >> > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---