Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

New functions for reading files iostream etc

Andrew_N_1
Beginner
291 Views

its been a fair while since I did c and c++ at university. What I'd like to know is what functions and headers are best for reading text from a file. I'm looking to read engineering data such as floats , doubles etc written as text in the file in various formats I.e some lines may have 4 floats and others may be more or a mix of text and floats. Is there a faster way than using sscanf and reading a line by fgets?

 

 

0 Kudos
1 Reply
Yuan_C_Intel
Employee
291 Views

Hi,

Searching from internet there are quite a lot of solution on this.

Using C++ iostream, read floats from text can be very simple. For example, see answer from:

http://stackoverflow.com/questions/8421170/read-floats-from-a-txt-file

Hope this helps.

Thanks.

0 Kudos
Reply