#include <iostream>
#include <fstream>


using namespace std;


int main(int argc, char* argv[])
{
	/*Create the file stream reference*/
	fstream fs;
	/*Open the file stream for writing*/
	/*fs.out = file as output*/
	/*fs.ate = file pointer at end (functionally the same as append)*/
	fs.open("stock.txt", fs.out | fs.ate);
	/*string to be written to the file*/
	char playerscore[] = { "PlayerOne\t345" };
	/*Write the string to a file*/
	for (int i = 0; i < 10000; i++) {
		fs.write(playerscore, sizeof(playerscore));
	}
	/*Flush the stream to finalise the write (not strictly necessarry)*/
	fs.flush();
	/*Close the stream for writing*/
	fs.close();
	/*Open the stream for reading*/
	fs.open("stock.txt", fs.in);
	/*Read until the end of the file to get file size (placing file pointer at the last byte)*/
	fs.seekg(0, std::ios::end);
	/*Get  the length of the file */
	long length = fs.tellg();
	/*Move file pointer back to the beginning of the file*/
	fs.seekg(0, std::ios::beg);
	/*Create an array large enough to store the contents of the file*/
	char *bytes = new char[length];
	/*Read the file providing the buffer to read the data into, provide length*/
	fs.read(bytes, length);
	/*Close the file*/
	fs.close();
	/*Display file contents*/
	cout << bytes;
	/*Free allocated memory*/
	delete(bytes);
	/*Retrieve input for length*/
	cin >> length;

	return 0;
}