I want to save data from a 20 by 60 array (yes its multidimensional -.-"), as well as save specific data in a formatted type of way, so that the data can be easily retrieved. However, I do not know how to output the data into the text file in a formatted way, and neither do I know how to retrieve it.
I looked on the website for help, but most of them just ...write one thing in and closed. Most of the time they are also conveniently already in string. I'm not sure if outputting more things cause problems.
#include <iostream>
#include <fstream>
#include <istream>
#include <ostream>
#include "struct.h"
usingnamespace std;
extern _OVERALL_ hero;
char map[20][60];
void saving (int counter)
{
ofstream save("save.txt");//open stream?
save<<map;//save the map-
save << "hero hp"<<hero.hp<<endl<< //save hero stats error here saying the same thing,
"hero attack"<<hero.ability.atk<<endl<< //as well as operand "expected a ;"
"hero defend"<<hero.ability.def<<endl<<
"hero agility"<< hero.ability.agi<<endl<<
"counter" <<counter <<endl<<
"name"<<hero.name;
save.close();//close connection
}
void loading ()
{
unsignedchar maze[20][60]; //array for map to be put into
char buffer[1220]; //buffer
ifstream load; //open stream
load.open ("save.txt");
Maps.getline(buffer,sizeof (buffer),'!'); //Retrieve characters in map and give it to buffer up until ! mark
//<----I don't know how retrieve specific information. at all.
}