Re: reading a file



robannexs@xxxxxxxxx wrote:
hi all..

i've got a file of the following format

10000000 records in
10000000 records out
5120000000 bytes (5.1 GB) copied, 628.835 seconds, 8.1 MB/s

how am i suppose to get the parameter 8.1MB/s on the third line?

If it always looks just like that, it should be easy to use scanf() or sscanf() to read it. Something like:

double rate;
scanf(fp, "%*s bytes (%*f GB) copied, %*f seconds, %lf MB/s",
&rate);

If the units at the end might change, store them in a string and multiply the rate accordingly.

--
Thomas M. Sommers -- tms@xxxxxx -- AB2SB

.



Relevant Pages

  • Re: Floating Point Number Problem
    ... What I want to do is, write those values in column vector G with 3 ... What I do is pass the vector in a string with sprintf where I set the ... format in '%.3e' and then pass that string into sscanf with the same ... Although the string follows the format I set, sscanf doesn't ...
    (comp.soft-sys.matlab)
  • Re: Multiple date formats in a Table
    ... a date field could not store just the year 2004 - it would have ... display it as 1 Jan 2004, or you would have to just display the year for all ... The conversion of your existing text format date should be done in a query, ... Public Function TextToDate(strDate As String) As Date ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Displaying dates in dd/mm/yy format
    ... the short date also contains time information. ... You can however format the string to shortformat. ... Can I somehow force Access to store the short ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Strip everything out of a string expect numbers.
    ... >>jcf wrote: ... >>>string that is stored in a buffer that can be any of the following ... > for the old format: ... > two sscanf expressions that will work on both strings. ...
    (comp.lang.c)
  • Re: Floating Point Number Problem
    ... What I want to do is, write those values in column vector G with 3 numbers after the comma. ... What I do is pass the vector in a string with sprintf where I set the format in '%.3e' and then pass that string into sscanf with the same format. ...
    (comp.soft-sys.matlab)