C Programming <stdio.h>

Discussion in 'Mac Programming' started by cybrscot, Feb 16, 2011.

  1. cybrscot macrumors 6502


    Dec 7, 2010
    Somewhere in Southeast Asia
    Just curious, so far I've used the <stdio.h> header for everything. Will I ever use anything else? If you were to break it down, what % of programming is the <stdio.h> header? 90%? 50%

    Just wondering how common this one is, and if others are just not as useful or for very specific purposes.

  2. lee1210 macrumors 68040


    Jan 10, 2005
    Dallas, TX
    You need this file for I/O (Input/Output). If you care to, you can look at it... it should be in /usr/include. Explaining the specifics might not be that helpful if you haven't used your own .h files yet. At a very high level, these files are used to define function prototypes (since you haven't used functions, what a function prototype is won't really make sense), constants using #define (don't think you've covered this yet, either), typedefs (probably not yet), structs (don't think you've seen them), and assorted other pieces of data you'll need to make use of a standard library. Basically, someone else wrote some code. You may or may not have access to the source code, but you do have a compiled library. They have provided you with a header file that will act as a guide for what functions are available (to help both you and the compiler) and what datatypes will be used when interacting with the library.

    A lot of programs make use of file and console I/O, so a lot of programs will use this file. I don't think anyone could say a percentage, but it's much closer to 100% than 0% or 50%.

  3. lloyddean macrumors 6502a

    May 10, 2009
    Des Moines, WA
    Any of the following 'Standard C' libraries are likely to be referenced sometime within your textbooks.


    And these not quite as much in the United States.

  4. cybrscot thread starter macrumors 6502


    Dec 7, 2010
    Somewhere in Southeast Asia
    Forgive me for this, because I don't have a teacher. I thought the "C library" was a single all encompassing "library" of everything of use related to C programming? Are you saying that each header you mentioned above, actually represents a "different and unique" library within C? And each library has different functions, etc?
  5. balamw Moderator


    Staff Member

    Aug 16, 2005
    New England
    This will become more clear to you by the time you get to chapter 9 and start writing your own functions. Not all code needs to be in a single function main or a single *.c file.

    Read: http://en.wikipedia.org/wiki/C_standard_library

    One library, several files and functions.

  6. jiminaus macrumors 65816


    Dec 16, 2010
    Lloyddean was being a bit loose with the language here. That list is a list of header files included in the 1 standard C library.

Share This Page