Search code examples
c++ifstream

ifstream not working in my code


I am making a kind of bot and i need to get some values from a document. The document will be wrote with some "First Time Setup". Well, the problem is, the program is not reading the values.

ifstream inFile;
inFile.open("D:\Bot\bin\Debug\Settings.in");

inFile >> i >> i2;
cout<<"Retrieving data..."<<endl;
cout<<" "<<endl;
Sleep(10000);
cout<<"SO: "<<i<<endl;
cout<<"BO: "<<i2<<endl;
Sleep(2000);

inFile.close();

I used the location where the .exe is. I can't figure out why it's not getting the values. I get 0 for both variables. I tried with a .txt file. Same thing.


Solution

  • \ is escape character. To have it in string it should be:

    inFile.open("D:\\Bot\\bin\\Debug\\Settings.in");