#### Archived

This topic is now archived and is closed to further replies.

# Writeing save files

## Recommended Posts

Another question, hopefully an easy one, how do you make your program make a save file that is not readable, or editable?? Like the ones that have machince code it it, hopefully I asked my question right hehe. Thx Jeff D Suffered seven plagues, but refused to let the slaves go free. ~ Ross Atherton

##### Share on other sites
quote:
Original post by Jeff D
Another question, hopefully an easy one, how do you make your program make a save file that is not readable, or editable??

That''s not possible in any computing environment I know of.
quote:
Original post by Jeff D
Like the ones that have machince code it it, hopefully I asked my question right hehe.

Those are still completely editable. However, since they''re just binary data they''re unintelligable without some information on their design or some effort on finding it out yourself. Here''s an example in C that shows how to write a number and then four characters to a file in binary:
  #include #include int main(void) { FILE *File; int Num = 123456; char Char[4] = { ''a'', ''b'', ''c'', ''d'' }; File = fopen("Output.dat","wb"); if(File == NULL) { fprintf(stderr,"Error creating file.\n"); return -1; } if(fwrite(&Num,sizeof(int),1,File) != 1) { fprintf(stderr,"Error writing Num.\n"); } if(fwrite(Char,sizeof(char),4,File) != 4) { fprintf(stderr,"Error writing Char.\n"); } fclose(File); return 0;}

##### Share on other sites
As I understood, you want a save file with binary code instead of text code, right ? It means that the information will be there but you will not see 126 as a number but as a binary value...OK! Use header and functions

functions -

int Handle;

open(-filename-,params);
write(-handle-, &variable, -size in bytes-);

see help

• ### Forum Statistics

• Total Topics
628306
• Total Posts
2981944

• 10
• 11
• 11
• 11
• 10