I get a warning in MSVC ++ when I try to read an integer from a file and make the bool variable equal to it.
accessLV[i] = FileRead(file1, i + 1);
(accessLV is an array of bools, FileRead is a function that I did to reduce the syntax involved in reading from a file, I - because the statement is in a for loop)
I tried using static_cast:
accessLV[i] = static_cast<bool>(FileRead(file1, i + 1));
But I still get a warning. I tried to do this (I'm not sure what this term is):
accessLV[i] = (bool)FileRead(file1, i + 1));
And the warning still exists. Is there a way to get rid of the warning without making accessLV an array of ints?
NB: this is FileRead syntax if it helps:
int FileRead(std::fstream& file, int pos)
{
int data;
file.seekg(file.beg + pos * sizeof(int));
file.read(reinterpret_cast<char*>(&data), sizeof(data));
return data;
}
user98188
source
share