![]() |
|
Allegro Save/Load |
thirdy
Member #8,409
March 2007
![]() |
Hi I'm doing allegro in devc++ and I got this error. I have no experience in doing file i/o, please help. 313 C:\Dev-Cpp\Projects\Project Jem\Mainmenu.h cannot convert `CHARSTATS' to `const void*' for argument `1' to `long int pack_fwrite(const void*, long int, PACKFILE*)'
int save() file = pack_fopen("file.sav", "wb"); pack_fwrite(jemstats, x, file); pack_fclose(file); if (file_select("Load Player (*.sav)", fname, "sav") == 0) file = pack_fopen(fname, "rb"); pack_fread(jemstats, sizeof(CHARSTATS), file); pack_fclose(file); |
LennyLen
Member #5,313
December 2004
![]() |
How is jemstats defined? And please use the code tags to make your post more legible.
|
thirdy
Member #8,409
March 2007
![]() |
ok, sorry
typedef struct { int Attack, Hp, Defense, Xp, Sword, Special; int Level; char Name[10]; }CHARSTATS;
|
DanielH
Member #934
January 2001
![]() |
1. For compatability, don't use fread, and fwrite. Instead load, save the individual variables.
|
LennyLen
Member #5,313
December 2004
![]() |
Quote:
I still see no definition of jemstats. The definition of the datatype it is an instance of is not the same thing. BTW, do you actually code without indentation, or did you just copy/paste the code from your earlier post and put code tags around it? Quote: 1. For compatability, don't use fread, and fwrite. The compatibility issues with the traditional fread() and fwrite() functions are not present in the pack_ versions. Quote: Instead load, save the individual variables. Why loop through the loading and saving of members of structs when allegro has a function for reading/writing blocks of them in one line? He used the right functions for the job, just incorrectly.
|
gnolam
Member #2,030
March 2002
![]() |
LennyLen said: The compatibility issues with the traditional fread() and fwrite() functions are not present in the pack_ versions. Actually, they are. Endianness is resolved, but data padding is still compiler- and platform-dependent. -- |
thirdy
Member #8,409
March 2007
![]() |
Finally I've done it thanks! I've just started programming//1st yr IT student what's wrong with this? if ( "C:/Dev-Cpp/Projects/Project Jem", "FILE.TXT", "TXT" ) == 0 ) { allegro_message("error loading file.txt"); }
BTW, do you any good site that gives free domains? My site, thirdy.tk is full of ads. |
Tobias Dammers
Member #2,604
August 2002
![]() |
Quote: Endianness is resolved, Not for raw pack_fread() / pack_fwrite() for all I know. These functions read / write raw byte streams, without any endianness considerations whatsoever. They have to, since all they get is a void*, which could contain anything - strings or char arrays, in which case the byte order needs to be preserved as-is, or larger int types where the byte order needs to be reversed in groups of 2 or 4, if the system's endianness requires it. --- |
gnolam
Member #2,030
March 2002
![]() |
Ah, yes, I was thinking about the pack_i* and pack_m* functions. My bad. -- |
BAF
Member #2,981
December 2002
![]() |
Quote: if ( "C:/Dev-Cpp/Projects/Project Jem", "FILE.TXT", "TXT" ) == 0 ) You have an extra ) (at least without ->) and a missiong function call / (. |
|