I have the following code:
#include <iostream>
#include <fstream>
int main(int argc, char *argv[]) {
if (argc != 2) {
std::cout << "Usage: basics <file>" << std::endl;
return 0;
}
std::basic_fstream<unsigned char> stream;
stream.open(argv[1], std::fstream::out);
stream.put('T');
stream.put('E');
stream.put('S');
stream.put('T');
stream.flush();
stream.close();
return 0;
}
The file is being created but there is nothing inside it when I open it in an editor.
My compiler is gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
.
What's wrong with it?