2

Functions like printf() , scanf() , memset() , puts() etc have their declaration in header files but is there any mechanism to see the definition of these function..? This might not be a new question but i could not find the appropriate solution for this.

Rajesh Sethi
  • 179
  • 2
  • 11
  • There is no mechanism. You have to get the source code elsewhere. – harper Mar 16 '15 at 13:27
  • Some environments have built in, context tools, such as right clicking a standard function and selecting help from a pull down context menu. But you can also just keep a browser page pointing to your favorite _man_ pages if Linux or MSDN if windows. – ryyker Mar 16 '15 at 13:30
  • When you say definition, is it the source code, the compiled library, or a human readable description of the function? Are you looking for man-pages? – Leonard Michlmayr Mar 16 '15 at 13:44
  • 1
    @ Leonard Michlmayr .. i am using windows... my doubt is where the compiler looks for the definition of these function while execution ? – Rajesh Sethi Mar 16 '15 at 13:50

1 Answers1

4
  • Find your compilers include path (e.g. GCC solution)
  • Search for the header you are interested in (e.g. printf should be in stdio.h or more likely another header included by stdio.h)
  • Correctly configured, some IDEs will help you with that, e.g. Eclipse

The method has its limits though, because at some point the include files will get less and less Standard-C, but more and more compiler dependent. The C-standard does not prescribe the contents of standard headers. It merely states that if you write #include <stdio.h>, you can use printf(). That does not necessarily mean that stdio.h has some form you might expect.

Community
  • 1
  • 1
edgar.holleis
  • 4,803
  • 2
  • 23
  • 27