Originally Posted by
vart
It was not a guess
You a missing
sizeof (*room_ptr );
How could you ran tests if you fail to read the simple line of code?
A little testy today, aren't we?
Every test shown above I ran. And yes, I missed this one. Thank you for pointing out my omission.
Code:
#include <stdio.h>
// a struct containing all the information which represents a room
struct room {
int room_id;
char *description;
int mob;
double exits[10];
char * puzzle;
} myroom, *room_ptr ;
int main (int argc, const char * argv[]) {
printf("sizeof(room) = %d\n", sizeof(myroom) ); // Use this...
printf("sizeof(struct room) = %d\n", sizeof(struct room) ); // Or this,
printf("sizeof(* room_ptr) = %d\n", sizeof(* room_ptr) ); // Or this.
printf("sizeof(room_ptr) = %d\n", sizeof(room_ptr) ); // But not this..
//printf("sizeof(* myroom) = %d\n", sizeof(* myroom) ); // and this generates a compile error
//printf("sizeof(* room) = %d\n", sizeof(* room) ); // and so does this.
return 0;
}
Todd