Reputation:
#include "StdAfx.h"
int main(int argc, char **argv)
{
// using namespace std;
string line;
cout<<"dsadasdas";
fstream file ("D:\source_details.txt", ios::in);
cout<<"dsadasdas"<<endl;
if (file.is_open())
{ cout<<"dsadasdas";
getline (file,line);
cout<<"dsadasdas";
cout<<line;
}
else
{
cout<<"Not possible"<<endl;
}
return (0);
}
the code doesnt get executed beyond the getline...... I get the unhandled exception error. I dont understand what is wrong with my code. It is really simple. Actually this is a very small part of a big code i am trying to run in visual studio but i keep getting this error.
Upvotes: 0
Views: 133
Reputation: 1719
fstream file ("D:\source_details.txt", ios::in);
You need to escape '\' symbol here, like this:
fstream file ("D:\\source_details.txt", ios::in);
Upvotes: 3