What is the reason to use a const char* for selecting the open mode instead of an enum like this:
enum open_mode {
READ,
READ_BINARY,
WRITE,
...
};
It wouldn't be more simply to use an enum?
What is the reason to use a const char* for selecting the open mode instead of an enum like this:
enum open_mode {
READ,
READ_BINARY,
WRITE,
...
};
It wouldn't be more simply to use an enum?
This is to provide freedom for implementations. For instance the implementation in VC++ has the possibility to select encoding and such: fopen("test.xml", "wt+,ccs=UNICODE")
The reason is most likely historical: function fopen has been around in the early K&R version of the language, while enum has been added to the language only for the ANSI standard.
By the time enums were added the language has been in such widespread use that changing the signature of such important function was impractical.