why we can write "stdio.h" instead of <stdio.h>

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abhinash sahoo
    New Member
    • Mar 2011
    • 2

    why we can write "stdio.h" instead of <stdio.h>

    Why does "stdio.h" instead of <stdio.h> work?

    Code:
    #include "stdio.h"//why C is not giving error here?
    void main()
    {
    printf("hello");
    getch();
    }
    Last edited by Niheel; Mar 15 '11, 02:40 PM. Reason: Use code tags and atleast explain your question.
  • vijay6
    New Member
    • Mar 2010
    • 158

    #2
    Hi friend,
    if you use the #include"stdio. h" then the turbo C compiler searches for the files in the c:/tc/include/lib directory and c:/tc/bin/ directory.If you modify the default file(stdio.h) in the c:/tc/include/lib directory and stored it in the c:/tc/bin/ directory then if you want to include both the files then use the #include"stdio. h" else if you want the default file only use the #include<stdio. h>.

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      I don't think that is correct.

      Using <stdio.h> tells the preprocessor to locate the stdio.h file in a "standard place". That is along a known path. These standard places are established as art of your compiler property settings.

      Using "stdio.h" tells the preprocessor to locate stdio.h in the same folder as the file you are compiling. If not there, then the search reverts to <stdio.h>.

      This technique lets you make a copy of a header that you want to change and place the copy in the folder with the file to compile. Now your code uses your modified header while everyone else uses the released header. When you have tested your changes, you copy your modified header on top of the released header and now everyone uses your modified header.

      Comment

      • donbock
        Recognized Expert Top Contributor
        • Mar 2008
        • 2427

        #4
        From the C99 specification
        6.10.2 Source file inclusion
        Constraints
        1 A #include directive shall identify a header or source file that can be processed by the implementation.
        Semantics
        2 A preprocessing directive of the form
        Code:
        #include <[I]h-char-sequence[/I]> [I]new-line[/I]
        searches a sequence of implementation-defined places for a header identified uniquely by the specified sequence between the < and > delimiters, and causes the replacement of that directive by the entire contents of the header. How the places are specified or the header identified is implementation-defined.
        3 A preprocessing directive of the form
        Code:
        #include "[I]q-char-sequence[/I]" [I]new-line[/I]
        causes the replacement of that directive by the entire contents of the source file identified by the specified sequence between the " delimiters. The named source file is searched for in an implementation-defined manner. If this search is not supported, or if the search fails, the directive is reprocessed as if it read
        Code:
        #include <[I]h-char-sequence[/I]> [I]new-line[/I]
        with the identical contained sequence (including > characters, if any) from the original directive.
        Thus, there are two reasons why you didn't get an error:
        1. How the two forms search for the specified file is implementation-defined. There is no necessity for there to be different search rules.
        2. The double-quote form decays into the angle-bracket form if the double-quote search fails.

        Comment

        • abhinash sahoo
          New Member
          • Mar 2011
          • 2

          #5
          thx buddy for the answer
          I really appreciate it

          Comment

          Working...