Jump to content
  • Advertisement
Sign in to follow this  
Lindon Heaven

saving a array

This topic is 5120 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

how do i save out a array in c the array is like theis Map_Array[200][10]; i can get it to print to a txt file but i want to be able to load and save it in a game. thanks

Share this post


Link to post
Share on other sites
Advertisement
this is the code i used and i need some how to save this out to a binary file format.

write error code


int Write_Error(char *string, ...)


{
// this function prints out the error string to the error file

char buffer[80]; // working buffer

va_list arglist; // variable argument list

// make sure both the error file and string are valid
if (!string || !fp_error)
return(0);

// print out the string using the variable number of arguments on stack
va_start(arglist,string);
vsprintf(buffer,string,arglist);
va_end(arglist);

// write string to file
fprintf(fp_error,buffer);

// return success
return(1);
} // end Write_Error






// code to save it to txt file


Open_Error_File("Array.txt");

for (int Map0=0;Map0<200;Map0++)

{
Write_Error("\n ");




for (int Map1=0;Map1<10 ;Map1++)

{
int array = Map_Array[Map0][Map1];
sprintf(buffer,"test = [%d] ", array);
Write_Error("(%d ):",array);



}


}


Close_Error_File();

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!