![]() |
|
pack_fread to array? |
Smok
Member #6,662
December 2005
|
Dev-Cpp 4.9.9.2; Allegro 4.2.0 Error: Where my thinking is wrong? Why doesn't it work? I'm just asking... :D |
BAF
Member #2,981
December 2002
![]() |
You would have to cast objects[x] to (void *). But, due to endianness and such, you shouldn't store whole structures like that. You should manually write/read each variable. |
Smok
Member #6,662
December 2005
|
You mean doing sth like this? pack_fread((void *) objects<i>,sizeof(object),params); It dosn't work: Cannot convert `*((+(((unsigned int)i) * 540u)) + objects)' from type `object' to type `void*' I don't care about endianness and such, cause this will be object-editor tool for my use only. Thanks anyway :] [EDIT] I'm just asking... :D |
CGamesPlay
Member #2,559
July 2002
![]() |
Quote: I don't care about endianness and such You should care about "and such", because it includes "compiler version and even compile itself". I.e. if you do that dont' expect your save games to work in the next version of your program. -- Ryan Patterson - <http://cgamesplay.com/> |
BAF
Member #2,981
December 2002
![]() |
I don't endorse what you are doing, writing the whole class to file, but, it would be pack_fread((void *)&objects<i>, sizeof(object), blah); . |
CGamesPlay
Member #2,559
July 2002
![]() |
But it's important to know that you can safely write entire arrays to a file at one time. That means: -- Ryan Patterson - <http://cgamesplay.com/> |
Kitty Cat
Member #2,815
October 2002
![]() |
Quote: But it's important to know that you can safely write entire arrays to a file at one time. Not if the structs/classes contain pointers to anything (which can include member functions). Running it once can have a different pointer than when you run it next time. -- |
CGamesPlay
Member #2,559
July 2002
![]() |
Well, I didn't say structures. I said arrays. We've already established that it isn't safe to write structures directly to files, with or without pointers. -- Ryan Patterson - <http://cgamesplay.com/> |
|