Thread: File Handling problem, please help

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    11

    File Handling problem, please help

    I have a data file, data.txt
    Code:
    1     0.011070     0.5100     0.4900     1.0211
    	9	2
    	11	19	8    7
    2     0.021373     0.1000     0.0870     1.1332
    	8	13
    	6	14	5    9
    and so on..

    The first no. is n (going 1,2,... till 100).
    Now, I am having a nightmare of a time in making a C code for reading this data.
    How can I make a C code to read data.txt, such that I can make the following matrices :

    a[1][1]=0.011070, a[1][2]=0.5100, a[1][3]=0.4900, a[1][4]=1.0211
    b[1][1]=9, b[1][2]=2
    c[1][1]=11, c[1][2]=19, c[1][3]=8, c[1][4]=7

    Similarly, for n=2 (4th, 5th & 6th rows)
    a[2][1]=0.021373, a[2][2]=0.1000, a[2][3]=0.0870, a[2][4]=1.1332
    b[2][1]=8, b[2][2]=13
    c[2][1]=6, c[2][2]=14, c[2][3]=5, c[2][4]=9

    and I go upto n=100.

    As is clear, I want matrix a to be float, and b and c as int.

    *The no. of columns of array a,b and c are same for all n.

    PLEASE KINDLY HELP SOON, AM BADLY STUCK.
    Regards
    Alice

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,633
    Please show your code, and any error/warning messages.

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading from file stream
    By shmitson in forum C Programming
    Replies: 0
    Last Post: 04-05-2011, 04:37 PM
  2. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 04:27 PM
  3. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  4. basic file handling problem
    By georgen1 in forum C Programming
    Replies: 4
    Last Post: 03-05-2009, 06:21 AM
  5. file handling and function problem.
    By prepare in forum C Programming
    Replies: 7
    Last Post: 10-09-2004, 02:26 AM