Struck in C++ coding. Need urgent help!?

Here I am providing a piece of my coding.

#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <fstream.h>
int main()
{
string line;
char word;

fstream dict ("c://example.txt",ios::in);
if (!dict.is_open())
{
cout << "Unable to open file";
exit(1);
}
cout<<"Enter word to search \n";
cin>>word;
while(getline(dict,line))
cout<<line<<"\n";

return 0;
}


Now when i compile, turbo c++ tells me that is_open is not a member of 'fstream'. Also, it tells me that getline prototype is missing. Now I really don't know what to do now.

I basically want to search a user provided string in a .txt file format and if the string exists, I want to continue my program and if it doesn't, I wish to take user input again.

Please don't give me lame answers. I have to be graded on it.
Thank you
Last edited on
fstream and getline are within the standard namespace.

Therefore, you need to do one of two things:

1.) Use using namespace std either in global scope (not recommended) or in a more localized scope (like the main() function).

2.) Prefix fstream and getline with std::
Topic archived. No new replies allowed.