Can you store / convert int values ββin bool variables?
2 answers
Just read the boolean variable:
bool b;
file >> b;
where file is your input file stream. 1 will be converted to true, from 0 to false.
If you've read the line, the obvious way to do the conversion is to look at the first character:
string s = .... // populate
bool b = s[0] != '0';
but I don't understand why you were reading the line if what you really want is a bool.
+6
anon
a source
to share