Problem with getting string
I am having trouble trying to get a first name string with this source file. Strangely enough, it works with getting a last name string.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <string.h>
#include "person.h"
void Person::setLastName(char *s)
{
strcpy (lastName, s);
}
char* Person::getLastName()
{
static char temp[21];
strcpy (temp, lastName); // last name is copied to temp which is returned
return temp;
}
//_________________________
void Person::setFirstName(char *f)
{
strcopy(firstName, f);
}
char* Person::getFirstName()
{
static char temp[16];
strcopy (temp, firstName);
return temp;
}
|
Last edited on
Topic archived. No new replies allowed.