read data in files

This is a discussion on read data in files within the C Programming forums, part of the General Programming Boards category; Hello my data is being written to a data file like this. 3.456 3.456 2.345 2.345 3.456 6.788 9.896 9.984 ...

  1. #1
    Unregistered
    Guest

    Cool read data in files

    Hello

    my data is being written to a data file like this.

    3.456 3.456 2.345 2.345
    3.456 6.788 9.896 9.984

    ... from left to right.

    I want to read the data in another program column wise.

    Like

    fscanf(fp,"%f, %f, %f, %f",&v1,&v2,&v3,&v4);

    having v1 hold the first column, v2 hold the second and so on need a little help.

    I am displaying it in GL but it is spitting it out fast like a counter, how to slow it down.

    Thanks

    D

  2. #2
    Registered User stormbringer's Avatar
    Join Date
    Jul 2002
    Posts
    90
    split the fscan command and put it in a loop with a lot of nops (stuf that does noting)

    stormbringer

    btw: i just know that the statement nop exists in assembly. is there an aquivalent in c? i just switched from assembly to c.

  3. #3
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Read the whole file into a 2d array and then display it however you want to.

  4. #4
    Registered User
    Join Date
    Jul 2002
    Posts
    45
    yes i think trollking is right.........

  5. #5
    Registered User
    Join Date
    Jul 2002
    Posts
    45
    If you are uncomfortable with 2d arrays, read the data into a single array and define colums as array[i] and array[i+4].

  6. #6
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    >3.456 3.456 2.345 2.345
    >fscanf(fp,"%f, %f, %f, %f",&v1,&v2,&v3,&v4);

    If the data stored in the file is delimitted with a spce, why are you reading it with fscanf() with a command as a delimiter? Remove the commas in your fscanf().

    >btw: i just know that the statement nop exists in assembly. is there an aquivalent in c? i just switched from assembly to c.
    Why do you need this in C though? You might just use a ;, if you really need it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. comparing data in two files
    By nynicue in forum C Programming
    Replies: 25
    Last Post: 06-18-2009, 08:35 PM
  2. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 11:13 AM
  3. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 02:30 PM
  4. Replies: 26
    Last Post: 06-15-2005, 03:38 PM
  5. read data from file
    By matth in forum C++ Programming
    Replies: 3
    Last Post: 04-21-2005, 10:37 AM

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