Harry Overs wrote:
I'm using the ifstream to read the contents of a file using the >>
operators.
However the problem that I have is that the file is made up of double and
string variables. Is there an easy way to read both types in or should I
just read it all in as char* and then convert to the correct format?
If you know which fields are double and which are string, than yes,
you could use the ">>" operator to easily read them:
myfile >> mydouble >> mydouble >> mystring >> ...
The trouble with reading strings via ">>" is, however, that
if you have spaces embedded in your strings they will split the
input by words. In that case you might want to look at the
get(...) and getline(...) functions.
HTH,
- J.