Thanks for the strcpy code! Now, when I compiled the first code w/ string.h and malloc, my compiler said 'malloc' was undeclared. I came up with this code:
Code:
char *name;
void setName(char *n) {
name = n;
}
Is this good or bad? I use it since the 'malloc' didn't work. Could you also describe what malloc does? Just from the name, I'm guessing it allocates memory...
I am also having trouble with this:
Code:
char *name; // already has value from setName()
char getName(void) const {
return *name;
}
name = getName();
Also tried this:
Code:
char *name; // already has value from setName()
char getName(void) const {
return name;
}
name = getName();
and this:
Code:
char *name; // already has value from setName()
char *getName(void) const {
return *name;
}
name = getName();
Even this!!:
Code:
char *name; // already has value from setName()
char *getName(void) const {
return name;
}
name = getName();
The last code I gave, compiler compiles, and a big bomb goes off in the DOS console. What do I do? They don't work. My compiler flags an error when I try to compile it.
-magicyte
Bookmarks