Tuesday, July 14, 2009

Reading data from file using C++?

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++

Reading data from file using C++?
You could use class ifstream.


It makes very easy to read from a file as an input stream.
Reply: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.


No comments:

Post a Comment