I am trying to make a get method in a class medicine to get the description. As I know of that in C++, there is no data type "String" like in Java, therefore I need to make an array of char to save the description. I couldn't find a way to make a method with return type "array of chars", I use a pointer like the following.
class Medicine {
public:
    char description[100] = "testing";
    char *getDescription() {
        char *p_description;
        char *p_subDescription = (char*)malloc(100 * sizeof(char));
        strcpy(p_subDescription, description);
        p_description = p_subDescription;
        free(p_subDescription);
        return p_description;
    }
};
I have a question: is there any other way I can do to make the code shorter? I feel like this is too much work just for a method to get a string.
Thank,
 
     
     
    