Thread: Reading files by dividing into parts

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2020
    Posts
    4

    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.

    Reading files by dividing into parts-6ecae09b-6ee9-49ca-a593-af099736cdca-jpg
    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++;
      }
      
    }
    Last edited by nothingelse; 03-25-2020 at 07:27 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 03-29-2012, 02:55 PM
  2. reading parts of a tab delimited file
    By AngKar in forum C Programming
    Replies: 8
    Last Post: 01-24-2006, 10:38 PM
  3. reading certain parts of text files
    By Captain Penguin in forum C++ Programming
    Replies: 2
    Last Post: 10-10-2002, 09:45 AM
  4. Reading from files
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 01-25-2002, 12:53 PM

Tags for this Thread