Read input file
| lmd141 (27) |
|
Hi there,
I'm currently trying to write a piece of code that reads input from a .txt file. Here is the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
void readconffile()
{
string dummystring;
string s;
ifstream Dfile;
std::stringstream out;
out << 1;
s = out.str() + ".TXT";
Dfile.open (s.c_str());
if (Dfile.fail())
{
return;
}
Dfile >> mass >> dummyint;
cout << mass;
Dfile >> sigma_ethane >> dummyint;
cout << sigma_ethane;
Dfile.close();}
|
Here is the text file:
30.07 !MASS
3.825 !SIGMA
However, the problem is that when I output "sigma_ethane" to screen, it simply comes up with 0, while mass works perfectly. Any ideas why this is?
Cheers
|
|
|
| cire (2357) |
|
|
!MASS is not an int that can be stored in dummyint?
|
|
|
Topic archived. No new replies allowed.