我有一些问题,我想阅读输入.txt文件参数并编写output.txt。我只能找到一行,我怎么能找到这个问题的所有行相同?当input.txt文件参数时删除,将删除output.file中的字符。
input.txt文件详细信息
write: 3 a 4 b 1 \n 2 d
delete: 1 a 2 b
output.txt将首先应用paramater结果
aaa bbbb
dd
output.txt将应用第二个参数结果
aa bb
dd
感谢你的回答
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
int main(void)
{
FILE *read, *write; /* files pointers */
char *source_file = "input.txt";
char *dest_file= "output.txt";
int count;
char ch;
char choose []="write";
int z=0;
if( (read=fopen(source_file, "r")) == NULL ) /* files check ? */
{
printf("%s didnt' open .\n", source_file);
exit(1);
}
if( (write=fopen(dest_file, "w")) == NULL )
{
printf("%s didnt. open \n", source_file);
exit(2);
}
fscanf(read,"%s%d%c",&choose,&count,&ch);
while( ( ch = fgetc(read) ) != EOF )
{
printf("%d%c",count,ch);
z=0;
for (; z<count; z++)
{
fprintf(write,"%c",ch);
printf("\n");
}
fprintf(write," ");
fscanf(read,"%d%c",&count,&ch);
printf("\n");
}
fclose(read); /* files close */
fclose(write);
printf("%s > %s\n",source_file, dest_file);
return 0;
}
答案 0 :(得分:0)
试试这个(省略一些检查):
FileUtils.cd('/home/ubuntu/projects/ruby-docker-heroku/blog')
require './config/boot'
require './config/environment'
Article # no more undefined constant error