展开全部
#include <stdlib.h>
#include <stdio.h>
#define Line 1024
int main()
{
//文件名及文件指针
char infile[]="D:\\Wtmp\\1.txt";
char outfile[]="D:\\Wtmp\\2.txt";
FILE *fpi,*fpo;
//暂存器
char *outbuf;
outbuf = (char *)malloc(Line*sizeof(char));
if( ( fpi=fopen(infile,"r") ) == NULL )
{
printf("文件打开%s失败\n",infile);
return 3;
}
if( ( fpo=fopen(outfile,"w") ) == NULL )
{
printf("文件打开%s失败\n",outfile);
return 3;
}
while(1)
{
//outbuf要干净
//memset(outbuf,0,Line);
outbuf=0;
fprintf(fpo,"%s",outbuf);
if (fgets(outbuf,Line,fpi)==NULL)
{
break;
}//全部行结束退出循环
//DelStr(outbuf,"删除字符串"); //重载函数DelStr
//DelStr(outbuf,"要替换字符串","替换成字符串"); //重载函数DelStr
fprintf(fpo,"%s",outbuf);
}
//关闭文件
free(outbuf);
fclose(fpi);
fclose(fpo);
return 0;
}
#include <stdio.h>
#define Line 1024
int main()
{
//文件名及文件指针
char infile[]="D:\\Wtmp\\1.txt";
char outfile[]="D:\\Wtmp\\2.txt";
FILE *fpi,*fpo;
//暂存器
char *outbuf;
outbuf = (char *)malloc(Line*sizeof(char));
if( ( fpi=fopen(infile,"r") ) == NULL )
{
printf("文件打开%s失败\n",infile);
return 3;
}
if( ( fpo=fopen(outfile,"w") ) == NULL )
{
printf("文件打开%s失败\n",outfile);
return 3;
}
while(1)
{
//outbuf要干净
//memset(outbuf,0,Line);
outbuf=0;
fprintf(fpo,"%s",outbuf);
if (fgets(outbuf,Line,fpi)==NULL)
{
break;
}//全部行结束退出循环
//DelStr(outbuf,"删除字符串"); //重载函数DelStr
//DelStr(outbuf,"要替换字符串","替换成字符串"); //重载函数DelStr
fprintf(fpo,"%s",outbuf);
}
//关闭文件
free(outbuf);
fclose(fpi);
fclose(fpo);
return 0;
}
展开全部
先向一个文本文件里写入你想要输入的文字,然后调用记事本打开这个文件
#include <stdio.h>
#include <process.h>
void main()
{
FILE *pFile = fopen("a.txt", "w");
char str[] = "你想要输入的字符串";
fwrite(str,1, sizeof(str)/sizeof(str[0]), pFile);
fclose(pFile);
system("notepad a.txt");
}
#include <stdio.h>
#include <process.h>
void main()
{
FILE *pFile = fopen("a.txt", "w");
char str[] = "你想要输入的字符串";
fwrite(str,1, sizeof(str)/sizeof(str[0]), pFile);
fclose(pFile);
system("notepad a.txt");
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询