A
anars
Hi,
I have this struct initialized globally:
struct riddle {
char *text;
....
}
below, the function I call in main with the riddle struct as arg. is
defined:
void prepareRiddle(struct riddle *riddle)
{
// here I get a string (char *tmp) with a known size (int length)
incl. terminator.
riddle->text = (char*)malloc(length * sizeof(char)); // figured
sizeof(char) could be != 1 on some platforms
....
}
still, sizeof(riddle.text) called in main() doesn't give me the numbers
I had hoped for.
Am I accessing the text member in my riddle struct inappropriately?
Thanks.
I have this struct initialized globally:
struct riddle {
char *text;
....
}
below, the function I call in main with the riddle struct as arg. is
defined:
void prepareRiddle(struct riddle *riddle)
{
// here I get a string (char *tmp) with a known size (int length)
incl. terminator.
riddle->text = (char*)malloc(length * sizeof(char)); // figured
sizeof(char) could be != 1 on some platforms
....
}
still, sizeof(riddle.text) called in main() doesn't give me the numbers
I had hoped for.
Am I accessing the text member in my riddle struct inappropriately?
Thanks.