here is my code c++ file handling
# include <conio.h>
# include <fstream.h>
main()
{
ifstream file ("Text.text");
ofstream nfile("NewText.text");
char row[1000];
char string[25];
int i;
if(!file)
{
cout<<"cannot open file"<<endl;
return 1;
}
for(i=1;i<=7;i++)
{
file.getline(row,1000);
cout<<row<<"\n";
if(!nfile)
{
cout<<"cannot open file"<<endl;
return 1;
}
}
for(i=1;i<=7;i++)
{
if(string =="for" || string =="every")
{
string == " ";
file.getline(row,1000);
cout<<row<<"\n";
}
}
file.close();
return 0;
}
this is the code that only shows the contents of the original file.
|