6
int main(void) {
void copiaConteudo(FILE *arquivo, FILE *arquivo1);
FILE *arquivo = fopen("tmp/exercicio.txt","r");
if (arquivo == NULL)
{
printf ("Não foi possível abrir o arquivo");
return 1;
}
FILE *arquivo1 = fopen("home/novo.txt","w");
copiaConteudo(arquivo,arquivo1);
fclose(arquivo);
fclose(arquivo1);
return 0;
}
void copiaConteudo(FILE *arquivo, FILE *arquivo1)
{
string teste;
teste = "Teste";
char ler[100];
while(fgets(ler,100,arquivo) != NULL)
if (ler.find("Teste"))
{
fputs("0/",arquivo);
}
else
{
fputs(ler, arquivo1);
}
}
I have this code, which my intention is to copy from the exercicio.txt file to the new.txt file, I can copy everything, but now I wanted to include a parameter for it not to copy the lines that contains "test".
Man if
there at the end is my attempt that did not work, how can I do this?
It seems that you want to do something simple, but not to understand well the explanation, I was able to detail ?
– Renan Silveira
The ideal is to read the file and search in memory. But it may be that the goal is another.
– Maniero
I want to copy everything in the exercicio.txt file to the new.txt file, but I want to create a parameter, for everything that starts with Test, not enter the fputs(read, archive1); which is the function that is copying the contents of the exercicio.txt file
– Guilherme Westrup
You have to decide which language wants to explain the problem. C is different from C++
– user5299