Why does C's "fopen" take a "const char *" as its second argument?

Posted by Chris Cooper on Stack Overflow See other posts from Stack Overflow or by Chris Cooper
Published on 2010-03-25T20:50:24Z Indexed on 2010/03/25 20:53 UTC
Read the original article Hit count: 268

Filed under:
|
|

It has always struck me as strange that the C function "fopen" takes a "const char *" as the second argument. I would think it would be easier to both read your code and implement the library's code if there were bit masks defined in stdio.h, like "IO_READ" and such, so you could do things like:

FILE* myFile = fopen("file.txt", IO_READ & IO_WRITE);

Is there a programmatic reason for the way it actually is, or is it just historic? (i.e. "That's just the way it is.")

© Stack Overflow or respective owner

Related posts about c

    Related posts about file-io