1 Attachment(s)
Reading files by dividing into parts
HOW CAN READ THİS FİLES BY DİVİDİNG PARTS? İ WANT TO READ NUMBERS AND LOAD TO STRUCT BEFORE 'END' AND THEN AFTER HAT_ID LINES LOAD TO ANOTHER STRUCT.
Attachment 16029
Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct musteri{
float id[10];
float x1[10];
float x2[10];
float x3[10];
float x4[10];
float x5[10];
}musteri;
struct hat{
float id[30];
float x1[30];
float x2[30];
float x3[30];
float x4[30];
}hat;
int main() {
FILE *dosya;
dosya=fopen("test.txt","r");
int SIZE =256;
int i=0;
int j=0;
char buff[SIZE];
while ( fgets(buff,SIZE,dosya) ) {
if ( buff[0] != 'E' ) {
sscanf(buff," %f %f %f %f %f %f ",&musteri.id[i],&musteri.x1[i],&musteri.x2[i],
&musteri.x3[i],&musteri.x4[i],&musteri.x5[i]);
i++;
}
if (buff[0] != 'A') {
sscanf(buff," %f %f %f %f %f ",&hat.id[j],&hat.x1[j],&hat.x2[j],
&hat.x3[j],&hat.x4[j]);
j++;
}
}