i want to know if we can use these three in a single program
i have designed a program to create a .txt file (if it doesn't already exist)
and to enter some line in it then display the line
but compiler shows declaration error
Here is my program Check it out thanks for your guidness
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
fstream file("Hassan.txt", ios::in | ios::out| ios ::trunc);
if(!file.is_open())
{
cout<<"ErroR";
}else
{
i want to know if we can use these three in a single program
Yes.
i have designed a program to create a .txt file (if it doesn't already exist)
and to enter some line in it then display the line
In your implementation, you attempt to open the same file for create, read and append at the same time. Does that seem reasonable to you?
but compiler shows declaration error
The normal way to deal with errors is to post the error exactly as the compiler produced it. In this case, you've declared all three file streams to have the same name. But the syntax error isn't the error you should focus on, but the error described above.