By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,655 Members | 1,005 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,655 IT Pros & Developers. It's quick & easy.

Question about fscanf ..

P: n/a
Hiho,

I have an ASCII-File with data from a simulation programm. It lookslike
this:

2.500000E+0026.911733E+0022.950929E+0054.746349E+0 040.000000E+0000.000000E+0
00
2.590362E+0023.806547E+0023.377923E+0057.040307E+0 040.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+0 030.000000E+0000.000000E+0
00
2.537223E+0026.500754E+0024.166493E+0056.221317E+0 040.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+0 040.000000E+0000.000000E+0
00
2.549374E+0025.902411E+0023.681309E+0056.965566E+0 040.000000E+0000.000000E+0
00
2.533486E+0026.700119E+0023.686952E+0055.628433E+0 040.000000E+0000.000000E+0
00
2.537227E+0026.500726E+0024.168410E+0056.231714E+0 040.000000E+0000.000000E+0
00
2.600828E+0023.426328E+0023.277678E+0055.456118E+0 040.000000E+0000.000000E+0
00
2.601910E+0023.427085E+0022.484092E+0053.851131E+0 040.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+0 040.000000E+0000.000000E+0
00
2.548747E+0025.907943E+0023.208793E+0054.656371E+0 040.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
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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+0 040.000000E+0000.000000E+0
00
2.590362E+0023.806547E+0023.377923E+0057.040307E+0 040.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

Jul 22 '05 #2

P: n/a
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
kb******@gascad.at
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.