Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //saving data into a file
- #define INFO_FILE "savefile.txt"
- new info[3] = {10, 20, 55}, File:myfile = fopen(INFO_FILE, io_write); // An array with integer data and our file variable
- if(myfile) // If file exist
- {
- for(new i = 0; i < 3; i++) // Iteration methode of getting the data from info array
- {
- new fstr[12]; //array (used as string)
- format(fstr, sizeof fstr, "%d", info[i]); //Formating the string...
- fwrite(myfile, fstr); // Writing the formated stuff into the file
- }
- fclose(myfile); // Closing our file
- }
- else printf("Couldn't open file '%s'.", INFO_FILE); // Otherwise...
Advertisement
Add Comment
Please, Sign In to add comment