tep_vd
#include"stdio.h"
#include"conio.h"
#include"iostream.h"
#include"iomanip.h"
#include"string.h"
void ghi(char *tentep)
{
int i,tl;
char dong[255];
FILE *f;
f=fopen(tentep,"wt");
clrscr();
i=1;
do
{
cout<<"
Nhap dong thu"<<i<<":";
gets(dong);
fputs(dong,f);
i=i+1;
cout<<"
Ban co nhap nua khong?"; cin>>tl;
}
while (tl==1);
fclose(f);
}
void doc(char *tentep)
{
char dong[255];
FILE *f;
f=fopen(tentep,"rt");
while (!feof(f))
{
fgets(dong,255,f);
cout<<dong<<"
";
}
fclose(f);
}
void saochep(char *tentep1,char *tentep2)
{
FILE *f1,*f2;
char dong[255];
f1=fopen(tentep1,"rt");
f2=fopen(tentep2,"wt");
while (!feof(f1))
{
fgets(dong,255,f1);
fputs(dong,f2);
}
fcloseall();
}
void main()
{
char *tentep1,*tentep2;
cout<<"
Nhap tentep1:"; gets(tentep1);
ghi(tentep1);
cout<<"
Noi dung tep vua tao la:";
doc(tentep1);
cout<<"
Nhap tentep2:"; gets(tentep2);
saochep(tentep1,tentep2);
cout<<"
Noi dung tep vua sao chep la:";
doc(tentep2);
getch();
}
Bạn đang đọc truyện trên: AzTruyen.Top