1

I have a program that is taking in a JSON file, of approx 170,000 characters total. I am saving them all to a text file (this part works fine) and then I am trying to read that entire text file back into a string:

json::value historicalData = value;
    ofstream outputFile("test.txt"); //output to file
    outputFile << historicalData; //store JSON into file
    ifstream inputFile("test.txt"); //input from file
    string historicalDataString="";
    string appendTemp;
    while(!inputFile.eof()){
    getline(inputFile,appendTemp); //store value from file into string
    historicalDataString.append(appendTemp);
    }

When I use this code above to read the file back in, I do not get the entire length of the file back. It stops about two thirds of the way, and is appending a "1" onto the end of my string. What am I doing wrong?

runesbane
  • 83
  • 7

1 Answers1

1
outputFile.close();

Solved my issues.

runesbane
  • 83
  • 7