I'm doing a practice project to save golf statistics. It will display different data using tables. I wanted to run it through a jar file. But when I exit, obviously all of the data in my arrayList is gone.

Any ways to save the arraylist?

thanks a lot,

-10100

You can load an array list using fstream. This example is used to draw maps.

int **map;
char c;
void draw(int Width,int Height){
	
	for ( int x=0;x<Width;x++)
	{
		for( int y = 0; y < Height; y++)
		{
			
			cout << map[x][y];
		}
		cout<<"\n";
	}
	delete map;	
}
bool Memalloc(int Width,int Height)
{

		map = new int*[Width];

		for( int x=0;x<Width;x++){
	
		map[x] = new int[Height];
		}
		
 
return true;
}
bool draw_map(char* Filename){


	int Width,Height;

	ifstream file;
	file.open(Filename);

	if(!file)return false;

    file >> Width >> Height;///two numbers separated by a white space at the beggining of the file
	Memalloc(Width,Height);

		while(!file.eof()){	
	
			for (int x=0;x<Width;x++){

				for(int y = 0; y <Height; y++){
						
					if(c!=']'){
						file >> map[x][y];//write map
						file.get(c);

					}

				}

			}
		
		}
	


	
	file.close();
	draw(Width,Height);
	return true;
}
This article has been dead for over six months. Start a new discussion instead.