Hello, I just started learning c++ and I'm dabbling with file input/output.
But now I have encountered an issue with this code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream inFile("values.txt", ios_base::binary);
string Value1;
int Value2;
int Value3;
int Value4;
if(inFile)
{
inFile.read((char*)&Value1, sizeof(string));
inFile.read((char*)&Value2, sizeof(int));
inFile.read((char*)&Value3, sizeof(int));
inFile.read((char*)&Value4, sizeof(int));
inFile.close();
}
cout << "Value1= " << Value1 << endl;
cout << "Value2= " << Value2 << endl;
cout << "Value3= " << Value3 << endl;
cout << "Value4= " << Value4 << endl << endl;
cout << "Loading sucessfull!" << endl;
system("PAUSE");
return 0
Everything works until the "return 0", then I get this error:
"Unhandled except at 0x103ead4a (msvcp100d.dll): Access violation reading location 0x003046b4"
I tried looking around on google, but I couldn't find the reason why I get this error or how to fix it.
Any help would be appreciated.