reading fortran data file from C program 
Author Message
 reading fortran data file from C program

Ok, here's perhaps a very simple problem, which I cannot figure out,
however.

I need to read text file, created by fortran program, from my C program.
It appears I have two columns of numbers in format %15.5E%15.5E. I want to
read them into two arrays mom[] and val[] (first number goes to the first
array and second to the second one).
    for (j=0;j<=nPoints-1,j++)

        fgets (line, 31, fp);
        sscanf (line, "%15.5E%15.5E",mom[j],val[j]);
    }
This program, however, reads some garbage. What could be the problem?

Thanks,

Sergey



Fri, 23 Aug 2002 03:00:00 GMT  
 reading fortran data file from C program
Hi,
It's just a plain text file isn't it, so the fact that it has been
produced by FORTRAN is immaterial.



Quote:
>         sscanf (line, "%15.5E%15.5E",mom[j],val[j]);

Change the arguments to pointers, so &(mom[j]), &(val[j])

Regards
Farid

Sent via Deja.com http://www.deja.com/
Before you buy.



Fri, 23 Aug 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Newbie: separate big .cs file into small .cs files

2. need help reading fortran unformatted file from a c program

3. reading data file from C program

4. program can't read its own data files

5. Can't Read Dbase data file from C program [HELP]

6. read Fortran created data into C programme

7. Reading file..Saving data in new file...

8. Writing binary files in C to be read in MS FORTRAN 4.0

9. read binary file written in fortran format

10. Reading FORTRAN binary files from C

11. Reading FORTRAN binary files from C

12. HELP!! fread reads Fortran Direct files incorrectly

 

 
Powered by phpBB® Forum Software