Reputation: 3774
Confession: I am a novice.
Question: I was checking out stdio.h
, but I could not find the definition of the fopen
function. Can somebody please tell where can I find the definition?
regards,
bug.
Upvotes: 4
Views: 397
Reputation: 106197
The implementation of fopen( )
for OS X (which is what the questioner is asking about) is available on opensource.apple.com:
http://opensource.apple.com/source/Libc/Libc-498.1.7/stdio/fopen-fbsd.c
I am curious, however, as to why you're looking for it; part of the point of libraries is that you don't need to know the details of how they work in order to use them effectively -- you need only know how to link against them and what the functions are defined to do.
Upvotes: 0
Reputation: 46
http://ftp.gnu.org/gnu/glibc/ There you can find c std. library source code
Upvotes: 2
Reputation: 393
You can find the definitions of functions in stdio.h here: http://en.wikipedia.org/wiki/Stdio.h
And here's an article on C file io: http://en.wikipedia.org/wiki/C_file_input/output
Upvotes: 3
Reputation: 13254
I found sourcecode here. am not a C-Coder so check the result for yourself. As far as I can tell, it looks like a real implementation. But even if it is not the "true" implementation it can at least give some hinds for the learning eyes. So it should be helpful, to know this file.
Upvotes: 0
Reputation: 35901
the declaration should be in stdio.h (afaik the standard requires this), but it's not likely you're going to find the definition there*. If you are using an open source os, it probably has packages containing source code (containing the definition) you can download. Else, sorry, no definition available.
*supposing the author considers definition to mean the actual implementation whereas declaration rather refers to function prototype
Upvotes: 4
Reputation: 147
alternatively, you can go on http://cplusplus.com/ under reference -> C Library -> cstdio (stdio.h)
Upvotes: 0
Reputation: 20875
extern FILE *fopen (__const char *__restrict __filename,
__const char *__restrict __modes) __wur;
As you said, in stdio.h
.
Upvotes: 2
Reputation: 127468
If you're using unix or linux you can find it with:
man fopen
Otherwise, just google for man fopen and you'll find it.
You can use man
for pretty much any standard library function.
Upvotes: 3