Are you trying to return a single character, or the whole string? That is to say:
Quote:
char * is a pointer and returning char* will return the address of the fname instead of the value in the array
Do you mean you just want one character, or the whole thing? If you just want the whole thing, returning a pointer to a character is what you want. Otherwise just return a single character and specify what character in the array you want to return.
Yes I am trying to return the whole array. At first when I had teh code above complie and run it return me an address (229...). I save close poject and reopen it and recompile and run and it return me the array' s value.
What's the problem? Other than missing the #include <cstring> to access strcpy, your code is fine and works. You cannot return an array, you can only return a pointer like you did. Functions that use the char* pointer as a C style string wil work as long as it is null-terminated, which it is by strcpy in this case.
Is there anyway to make a class hold string values?
example:
Code:
#include <cstring>
class a
{
string b;
}
i get error doing the above for some reason