Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!ux1.cso.uiuc.edu!uxa.cso.uiuc.edu!nnj20229 From: nnj20229@uxa.cso.uiuc.edu (Nesha Nicole Jones) Newsgroups: comp.lang.c Subject: returning automatic variables Summary: Can you return a string from a function Keywords: automatic variables, returning values Message-ID: <1991May24.153133.13590@ux1.cso.uiuc.edu> Date: 24 May 91 15:31:33 GMT Sender: usenet@ux1.cso.uiuc.edu (News) Organization: University of Illinois at Urbana Lines: 31 I wrote the following simple program and when it runs I get the following output. Is it possible to return an automatic string form a function because I cannot get it to work. #include main() { char machine[100]; char *word(void); sprintf(machine,"%s",word()); printf(" the value of name after the function call is %s\n",machine); } char *word(void) { char name[100]; printf("enter a value for name : "); scanf("%s",name); return name; } ******************* output *********************************** enter a value for name : nesha the value of name after the function all is oo$ ** I copied this directly from the screen , you could not see the ^?^?o^?o^?$