returning automatic variables
Nesha Nicole Jones
nnj20229 at uxa.cso.uiuc.edu
Sat May 25 01:31:33 AEST 1991
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 <stdio.h>
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^?$
More information about the Comp.lang.c
mailing list