Hello..
Im working on a class that would store different variables for my application..
It would be possible to store char * (string), char ** (string list), and integer.Code:class datalist { public: datalist() {} char *name; unsigned short type; void *p; datalist *next; };
type 0 = integer, 1 = string, 2-> = string list (the number of strings)
p is the pointer to data.
Is it smart doing things like that?
I want a function that would return string (if char*) or first string (if char**)
The code is not okay, I get error if I cast (char**)(read)->p[0] - "'void *' : unknown size".. Im not sure how should I do it? Is it smart doing things that way?Code:int readdata(datalist *read) { char *value = 0; if (read && read->type) { if (read->type > 1) value = (char **)(read)->p; // <- problem else value = (char *)(read)->p; printf("value: %s\n", value); } return 0; }



LinkBack URL
About LinkBacks


