10

I could find stdio.h header file easily through search in Windows Explorer, but couldn't find its implementation file like stdio.lib(?). Where can I find it?

Additionally, I can't find Windows.h through search in Windows Explorer, although I can compile source code with Windows.h included.

Is there anybody to explain about this?

David Johns
  • 1,201
  • 5
  • 15
  • 34

3 Answers3

6

The sources for the CRT (C Runtime) are included in the Visual Studio install directory, under VC\crt\src. There are many files; you'll need to find the one that defines the functionality in which you are interested.

The Windows headers (including Windows.h) are included in the Windows SDK, in which there is an Include directory which contains the headers. Where exactly these files are located on your computer depends entirely on where you installed the Windows SDK.

James McNellis
  • 348,265
  • 75
  • 913
  • 977
  • But, implementation file for stdio.h didn't seem to be found there... I can compile source code that contains printf() with stdio.h included. Linker doesn't report any error at all. Somewhere in my hdd implementation code for stdio.h must be exist. Where can I find it? I know this can be somewhat funny or easy question. But I don't know the answer and am just curious about it. :-$ – David Johns Dec 10 '12 at 13:58
  • The source code is in **printf.c** under the directory noted in the answer. The library is in whichever one of the [C Runtime Libraries](http://msdn.microsoft.com/en-us/library/abx4dbyh.aspx) against which you are linking. Those libraries are in the **VC\lib** folder in the Visual Studio installation directory. – James McNellis Dec 10 '12 at 17:48
  • Thanks for your answer. I found printf.c file. But, still I don't know why my helloworld project build so well although I never imported printf.c in my project and never compiled it. That only means linker found implementation of printf() in some place out of my project. In my project property page > Config. property > Linker > Input > Additional dependencies there are some .lib files such as kernel32.lib, user32.lib, gdi32.lib, ... Is implementation code of printf() funciton in one of these .lib files? – David Johns Dec 11 '12 at 14:57
  • It's in each of the C Runtime Libraries, one of which is linked into your program, depending on which flag is passed to the compiler. See the page to which I linked in my previous comment. – James McNellis Dec 11 '12 at 16:09
0

Based on accepted answer. For VC++6, it typically locates on:

C:\Program Files (x86)\Microsoft Visual Studio\VC98\Lib\MSVCRT.LIB

Verify it by opening that file with Notepad, and search '_printf'.

Nianliang
  • 2,926
  • 3
  • 29
  • 22
0

Since 2015, you have to install "Universal CRT SDK". Then you can find the code from C:\Program Files (x86)\Windows Kits\10 directory.

You can see here from more details. https://devblogs.microsoft.com/cppblog/introducing-the-universal-crt/

frogred8
  • 1
  • 3