Why doesn't the "fopen" function use enumerations?

What is the reason for using const char* to select open mode instead of enum as follows:

 enum open_mode { READ, READ_BINARY, WRITE, ... }; 

Wouldn't it be easier to use an enumeration?

+2
source share
2 answers

The reason is most likely historical: the fopen function was in an early version of the K & R language, and enum was added to the language only for the ANSI standard.

By the time enum was added, the language was widely used that changing the signature of such an important function was impractical.

+4
source

This provides freedom for implementation. For example, the implementation in VC ++ allows you to select the encoding and such: fopen("test.xml", "wt+,ccs=UNICODE")

+4
source

All Articles