Returning a Pointer to a Static Local Variable
#include <iostream>
using namespace std;
char * setName();
int main (void)
{
char* str = setName();
cout << str;
return 0;
}
char* setName (void)
{
static char name[80];
cout << "Enter your name: ";
cin.getline (name, 80);
return name;
}
Related examples in the same category