Like Tree1Likes
  • 1 Post By quzah

How to read text file into variables

This is a discussion on How to read text file into variables within the C Programming forums, part of the General Programming Boards category; I have data file like this. I want to read this file in C. After reading this file I want ...

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    1

    How to read text file into variables

    I have data file like this. I want to read this file in C. After reading this file I want it to be stored in variables like this M=5 N=8 NRHS=3 JSGN=0 IOUT=0 JDCYC=0
    From the second line onwards since KC(1) =1 it should have JJ(1)=5 values and third line details the values KM(1) =1, KL (1) =120 , KM(2) =5, KL (2) =170, KM(3) =3, KL (3) =180, KM(4) =2, KL(4) =210, KM(5)=4, KL(5) =210 and procedure then repeats for 1 to M The last three likes should be stored in variables IFC(1) = 100, IFC(2) =70 ......................

    5 8 3 0 0 0
    1 5
    1 120 5 170 3 180 2 210 4 210
    2 4
    5 150 1 180 3 190 4 190
    3 5
    1 100 3 110 5 110 2 150 4 150
    4 4
    5 150 4 180 3 195 2 240
    5 5
    3 50 2 55 1 60 4 65 5 70
    6 3
    4 120 5 195 2 210
    7 4
    2 110 4 160 1 180 5 200
    8 3
    4 120 2 165 3 195
    100 70 60 110 80
    100 100 100 150 100
    200 200 200 400 300

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    fread, fscanf, fgets, fgetc, pick one.


    Quzah.
    TheBigH likes this.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Read text file, scan and store data into variables?
    By wisdom30 in forum C Programming
    Replies: 8
    Last Post: 04-18-2011, 11:23 PM
  2. Getting variables and numbers from a text file.
    By snoikey in forum C Programming
    Replies: 29
    Last Post: 07-13-2010, 07:26 AM
  3. Replies: 4
    Last Post: 07-16-2009, 05:07 PM
  4. Read variables and stuff from a text file
    By ChrisJ in forum C++ Programming
    Replies: 1
    Last Post: 06-26-2003, 11:06 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21