HELP reading txt file

Below is a snippet of my code:


int counter = 0;

in.ignore(1000,':');
in >> dataFile;
cout << dataFile;

ifstream dataFile;


readData( in, ISO, ISO3, ISO_Numeric, fips, Country, Capital, Area, Population, Continent, tld, CurrencyCode, CurrencyName, Phone, PostalCodeFormat, PostalCodeRegex, Languages, geonameid, neighbors, EquivalentFipsCode );

I am trying to read the variable dataFile which is storing "countryInfo.txt".

ifstream dataFile; is not working, neither is anything else I have tried.

Any help would be appreciated. Thanks.
Last edited on
ifstream is a type, so you need to create a variable of that type and then use dataFile to open the stream.

1
2
3
4
5
ifstream fin(dataFile);

// OR
ifstream fin;
fin.open(dataFile);


fin is an arbitrary name but I think of it as f(ile)in as opposed to c(onsole)in. You should also verify that the file was opened properly with an if statement or assert().
Topic archived. No new replies allowed.