ovo je moj neuspjeli pokusaj:
Code:
#include<iostream>
#include<fstream>
using namespace std;
void main()
{
char y[200];
char temp[200];
fstream x("c:\\recenica2.txt",ios_base::in);
if(!x)
{
cout<<"Nepostojeca datoteka"<<endl;
x.clear();
x.open("c:\\recenica2.txt",ios_base::out);
cout<<"Unesite recenicu: ";
gets(y);
x<<y<<endl;
x.close();
}
x.open("c:\\recenica2.txt",ios_base::in | ios_base::out);
do
{
x>>y;
}while(!x.eof());
cout<<"Vasa stara recenica glasi: "<<y<<endl;
cout<<"Unesite novu recenicu :";
gets(y);
x.clear();
x<<y<<endl;
if(x.fail())
{
cout<<"Nije uredu upis"<<endl;
}
else
{
cout<<"Nova recenica: "<<y<<endl;
}
}
#include<iostream>
#include<fstream>
using namespace std;
void main()
{
char y[200];
char temp[200];
fstream x("c:\\recenica2.txt",ios_base::in);
if(!x)
{
cout<<"Nepostojeca datoteka"<<endl;
x.clear();
x.open("c:\\recenica2.txt",ios_base::out);
cout<<"Unesite recenicu: ";
gets(y);
x<<y<<endl;
x.close();
}
x.open("c:\\recenica2.txt",ios_base::in | ios_base::out);
do
{
x>>y;
}while(!x.eof());
cout<<"Vasa stara recenica glasi: "<<y<<endl;
cout<<"Unesite novu recenicu :";
gets(y);
x.clear();
x<<y<<endl;
if(x.fail())
{
cout<<"Nije uredu upis"<<endl;
}
else
{
cout<<"Nova recenica: "<<y<<endl;
}
}
hvala unaprijed a ako nekom nije mrsko nek napise kod za brisanje neke recenice iz datoteke(Prve ili zadnje bilo koje).