You don't return a local string from a function because local variables are destroyed when the function returns. In most cases the best option is to pass a buffer as an argument to the function:
Code:
void studentName ( char name[50] )
{
printf ( "\n\nPlease enter student's name: " );
fflush ( stdout );
scanf ( "%49[^\n]", name );
printf ( "\n\nStudent's name is %s\n", name );
}
...
char name[50];
studentName ( name );
Then you can return a pointer to the buffer for further convenience:
Code:
char *studentName ( char name[50] )
{
printf ( "\n\nPlease enter student's name: " );
fflush ( stdout );
scanf ( "%49[^\n]", name );
return name;
}
...
char name[50];
printf ( "\n\nStudent's name is %s\n", studentName ( name ) );