| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"Marc Reclaire" |
| Date: |
17 Dec 2003 06:16:42 PM |
| Object: |
Question about fscanf .. |
Hiho,
I have an ASCII-File with data from a simulation programm. It lookslike
this:
2.500000E+0026.911733E+0022.950929E+0054.746349E+0040.000000E+0000.000000E+0
00
2.590362E+0023.806547E+0023.377923E+0057.040307E+0040.000000E+0000.000000E+0
00
-1.000000E+000-1.000000E+000-1.000000E+000-1.000000E+0000.000000E+0000.00000
0E+000
2.530572E+0022.145215E+0021.750804E+0053.285819E+0030.000000E+0000.000000E+0
00
2.537223E+0026.500754E+0024.166493E+0056.221317E+0040.000000E+0000.000000E+0
00
-1.000000E+000-1.000000E+000-1.000000E+000-1.000000E+0000.000000E+0000.00000
0E+000
2.547310E+0025.723339E+0023.675294E+0055.031395E+0040.000000E+0000.000000E+0
00
2.549374E+0025.902411E+0023.681309E+0056.965566E+0040.000000E+0000.000000E+0
00
2.533486E+0026.700119E+0023.686952E+0055.628433E+0040.000000E+0000.000000E+0
00
2.537227E+0026.500726E+0024.168410E+0056.231714E+0040.000000E+0000.000000E+0
00
2.600828E+0023.426328E+0023.277678E+0055.456118E+0040.000000E+0000.000000E+0
00
2.601910E+0023.427085E+0022.484092E+0053.851131E+0040.000000E+0000.000000E+0
00
-1.000000E+000-1.000000E+000-1.000000E+000-1.000000E+0000.000000E+0000.00000
0E+000
2.548592E+0025.911483E+0023.347479E+0054.669881E+0040.000000E+0000.000000E+0
00
2.548747E+0025.907943E+0023.208793E+0054.656371E+0040.000000E+0000.000000E+0
00
You can see that there are 6 columns. Im interested in the second column.
But I dont know how to access this column. I tried several options with
fscanf. But nothing worked. Anybody knows how to do it?
I tried something like that:
fscanf(temp, "%f %f %f %f %f %f", var, var 2 .... ); Tried the Options
E and so on ..
Thx for help.
Greetings Marc
.
|
|
| User: "Karl Heinz Buchegger" |
|
| Title: Re: Question about fscanf .. |
18 Dec 2003 06:51:32 AM |
|
|
Marc Reclaire wrote:
You can see that there are 6 columns. Im interested in the second column.
But I dont know how to access this column.
Read all 6 and use only the 2-nd
I tried several options with
fscanf. But nothing worked. Anybody knows how to do it?
I tried something like that:
fscanf(temp, "%f %f %f %f %f %f", var, var 2 .... ); Tried the Options
E and so on ..
If you want us to help you sort out your errors you have to post real
code.
--
Karl Heinz Buchegger
kbuchegg@gascad.at
.
|
|
|
|
| User: "Jeffrey Schwab" |
|
| Title: Re: Question about fscanf .. |
17 Dec 2003 06:29:47 PM |
|
|
Marc Reclaire wrote:
Hiho,
I have an ASCII-File with data from a simulation programm. It lookslike
this:
2.500000E+0026.911733E+0022.950929E+0054.746349E+0040.000000E+0000.000000E+0
00
2.590362E+0023.806547E+0023.377923E+0057.040307E+0040.000000E+0000.000000E+0
00
<snip/>
You can see that there are 6 columns. Im interested in the second column.
But I dont know how to access this column. I tried several options with
fscanf. But nothing worked. Anybody knows how to do it?
I tried something like that:
fscanf(temp, "%f %f %f %f %f %f", var, var 2 .... ); Tried the Options
E and so on ..
Are you parsing a tr0?
In what way did fscanf not work? Did you get a compile-time error, or a
fatal, run-time error, or did the correct values just not end up in the
variables? What are the types of var and var2?
My guess is that var and var2 are single-precision, and that your floats
just aren't big enough. <insert> witty crack about genetics. </> If
so, try declaring them as doubles.
-Jeff
.
|
|
|
|

|
Related Articles |
|
|