Hello All;
I am trying to make a copy of a file in another file using C. But the content of the file should be repeted the quantity of times of the lines of a third file
{
int num = 0;
int x;
char cont;
FILE *file;
file = fopen("string.csv","r");//w= write r=read a=alterar
if(file == NULL){
printf("Arquivo não encontrado!\n");
getchar();
return 0;}
while( (cont=fgetc(file))!= EOF ){
if(cont == '\n')
num--;}
printf("Existem %d linhas no arquivo\n", num);
fclose(file);
FILE *file2, *file3;
file2 = fopen("string.txt","r");//w= write r=read a=alterar
if(file2 == NULL){
printf("Arquivo não encontrado!\n");
getchar();
return 0;}
file3 = fopen("string2.txt","w");//w= write r=read a=alterar
char texto[1000];//The problem is the repetition
while(fgets(texto,1000,file2)!= NULL){
while{
for(x=0;x<=num;x++){
fputs(texto,file3);
}
fclose(file3);
return 0;
Can anyone to help me ?
Thanks !