Traitement-signal-plantes/Code-C/fileGestion.c

17 lines
457 B
C
Raw Normal View History

2022-06-01 12:32:04 +02:00
#include "fileGestion.h"
2022-06-01 17:01:23 +02:00
void clearRawData(int N){
2022-06-01 12:32:04 +02:00
char buffer[256];
2022-06-01 17:01:23 +02:00
FILE *f = fopen("newFile.txt","w+");
FILE *g = fopen("rawData.txt","r");
for(int i = 0; i < N; i++){
fgets(buffer , sizeof buffer , g);
2022-06-01 12:32:04 +02:00
//printf("Line contaigns: %s" , buffer);
}
while(1){
2022-06-01 17:01:23 +02:00
if(!fgets(buffer,sizeof buffer , g)) break;
2022-06-01 12:32:04 +02:00
fprintf(f,"%s",buffer);
}
2022-06-01 17:01:23 +02:00
remove("rawData.txt"); rename("newFile.txt", "rawData.txt");
2022-06-01 12:32:04 +02:00
}