I am trying to write a matrix to a file with the above code. But i got the following error: 'ios' : is not a class or namespace name. My code:
std::ofstream myfile;
myfile.open ("C:/Users/zenitis/Desktop/bots/Nova/data/ownStatus.txt", ios::out | ios::app);               
for (int i = 0; i< 21; i++){
    myfile << featureMatrix[i] << "          ";
}
myfile << "\n";
myfile.close();
Any idea about this problem??
ios is a member of std. That is, you want to use one of the following approaches to refer to it:
using namespace std; // bad
using std::ios;      // slightly better
int main() {
    std::ofstream myFile("name", std::ios::app); // best
}
BTW, you can open() the std::ofstream directly in the constructor. Also, for std::ofstream the flag std::ios_base::out (the opening flags are actually defined in std::ios's base class std::ios_base) is added automatically.
It is actually std::ios::out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With