I am trying to write and read from a file in the same cpp program, but i am getting 3 errors
conflicting decleration 'std::istream theFile'
'theFile' has a previous decleration as 'std::istream theFile'
no match for 'operator>>' 'in theFile >>n'
while you answer this question try to be more noob specific. here is my code.
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
int n;
string name;
ofstream theFile;
istream theFile;
theFile.open("Olive.txt");
while(cin>> n>>name)
{
theFile<< n<<' '<< name;
}
while(theFile>>n>>name)
{
cout <<endl<<n<<","<<name;
}
return 0;
}