Question:
Reading data from file using C++?
cajun_guy17
2007-10-18 09:24:34 UTC
I have a text file representing time-voltage signal 2 colums of numbers, in scientific format eg.
time voltage
0.003 1.553e-8
... ...

how do I read them into a mx2 matrix using C++?

used to working with C, not familar with C++
Three answers:
halen_shezar
2007-10-18 09:40:17 UTC
You could use class ifstream.

It makes very easy to read from a file as an input stream.
Pfo
2007-10-18 13:59:06 UTC
If you are not required to use the C++ library, then use the C one. I always preferred the C one. Even in my college courses, where we were expected to use C++ I was not penalized for using the standard C library. If you are going to school, you might want to double check if this is acceptable. IMO the C++ standard library using too confusing and abstracted of a syntax to be understandable. Plus I knew how to look at standard C code on paper and determine what the result would be, in C++ I wasn't and still can't always do this.
anonymous
2016-10-04 06:26:42 UTC
What you have sounds like it reads the information and straight away throws it away. i'm able to comprehend putting it down yet at the same time as (one million) { ch=fgetc(fs); if(ch==EOF) injury; } in simple terms reads, yet would not exhibit or shop, characters. i'm sorry, how do you know it is not reading it?


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...