#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0

    Read a huge text file >20MBthorugh C


    I m trying to read a text file (>20MB in size) through C. The file is created by the statement:
    fprintf(fp,"%0.9lf\n",r_diff);
    I m trying to read this file using the following statement:
    fscanf(fp,"%0.9lf",&r[i]);
    where double r[9]; is an array and int i; is a loop variable. But each time i m getting 0.0000000000 as an output for each read. Please suggest me a solution in C only.
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,997
    Rep Power
    481
    You don't happen to get warnings from fscanf when you compile the program? These could be important.

    warning: zero width in gnu_scanf format [-Wformat]
    warning: unknown conversion type character . in format [-Wformat]
    warning: too many arguments for format [-Wformat-extra-args]


    Without providing too many hints, why don't you try a scanf conversion similar to
    "%lf"
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo