From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Read specific data from file and do a calculation and display on the output

FYI: Below is the function use for the writing:

-OpenFile(use ASCII)
-sprintf
-WriteFile

 

Example: Output from the doc file

…EndTime: 09:34:48 program time: 0.567663 sec
…EndTime: 09:36:48 program time: 0.666666 sec

 

My objective is to read data 0.666666 (FYI: is last sentence of the file) to do some calculation. How can we read specific data(specific location) from file..

Any advice or help?
What is the function needed?

0 Kudos
Message 1 of 2
(3,973 Views)

I would consider counting line feeds and checking for end-of file to isolate the last line, which then can be read using fscanf...

 

Have a look at getc...

 

character = fgetc ( stream );

 

if ( character == '\n' ) // new line

if ( character == EOF ) // end-of-file

 

 

0 Kudos
Message 2 of 2
(3,962 Views)