流浪啊
新手上路

UID 75778
精华
0
积分 2
帖子 2
金钱 2 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2006-6-30
状态 离线
|
[推荐阅读] 这个PHP为什么没有反应呢???
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i=0;
char tem[80],tem1;
FILE *infile,*outfile;
infile=fopen("hello.txt","r");
if(!infile)
{
cout<<"error infile1 don't open";
exit(0);
}
outfile=fopen("tem.txt","w");
if(!outfile)
{
cout<<"error outfile1 don't open";
exit(0);
}
tem[i++]=tem1=fgetc(infile);
while(1)
{
while(tem1!='\n'&&tem1!=EOF)//按行读出文件内容
{
tem1=tem[i++]=fgetc(infile);
}
for(int j=i-2;j>=0;j--)//反向输出到临时文件中
{
fputc(tem[j],outfile);
}
fputc(tem[i-1],outfile);
if(tem1==EOF)
{
break;
}
else
{
i=0;
tem1=tem[i++]=fgetc(infile);
}
}
fclose(infile);
fclose(outfile);
// outfile=fopen("hello.txt","w");
// if(!outfile)
// {
// cout<<"error outfile2 don't open";
// exit(0);
// }
// infile=fopen("tem.txt","r");
// if(!infile)
// {
// cout<<"error infile2 don't open";
// exit(0);
// }
// while((tem1=fgetc(infile))!=EOF)//
// fputc(tem1,outfile);
// fclose(infile);
// fclose(outfile);
system("del /q hello.txt");
system("ren tem.txt hello.txt");
return 0;
}
|
|