Hello, i was wondering if ofstream, ifstream and fstream are for writing, reading, and writing and reading purposes respectively, for what are the tags ios::in, ios::out, and ios::out | ios::in?.
I mean, if i put the ios::out to a ifstream object i can't put strings in the file, so it seems to me that ofstream, ifstream and fstream make the rules of what you can and can't do.
For example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
#include <fstream>
int main() {
std::ifstream archivo;
archivo.open("ejemplo.txt", std::ios::out);
if (!archivo.is_open()) {
std::cout << "Error en la apertura del archivo\n";
return 0;
}
std::string linea = "hola como estas";
archivo << linea;
}
That launch me a lot of errors, but if i just change the ifstream by a fstream or ofstream it compile perfectly, so again, for what are the ios::out, ios::in?.