Reputation: 107
Is there any standard cross-platform analogue for file-io in c/c++ to
int open(const char *pathname, int flags, mode_t mode);
?
Upvotes: 2
Views: 4260
Reputation: 1723
File descriptors aren't cross platform, they belong to POSIX standard, so they will work on Linux/Unix-like systems only.
Upvotes: 3
Reputation: 91
int open(const char *pathname, int flags, mode_t mode)
is not C++. It is pure C.
You should use std::fstream
( http://www.cplusplus.com/reference/fstream/fstream/ )
#include <fstream>
int main () {
std::fstream fs;
fs.open ("test.txt", std::fstream::in | std::fstream::out | std::fstream::app);
fs << " more lorem ipsum";
fs.close();
return 0;
}
Upvotes: 8