Thread: Which of the C 'Standard Library headers' are worth rembering?

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    45

    Which of the C 'Standard Library headers' are worth rembering?

    I'm taking a look and i notice that there are atleast 15 C Standard Library headers that are part of being ANSI compliant. I'm going through some of them and some of them are filled with functions, types, constants. So I'm wondering do people actually memorize these, if not whcih ones should I memories (I'm guessing stdio.h is one of the most important ones).

    Also in the case where a library adds a "type" does that mean that it is creating a new type (would it be a type like int, double, float, etc.)?
    With these new 'types' do I have to do something special to use them (im trying to use FILE type).
    Also can I just make up types whenever I want, and if so how? (=

    Thanks again.
    -Raven's Wrath

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Off the top of my head, for C I remember the following:

    • stdio.h
    • stdlib.h
    • malloc.h
    • string.h
    • ctype.h
    • limits.h


    The most important ones for basic things are stdio.h, stdlib.h, and string.h.

    FILE is just a struct of some sort. Types like size_t are usually typedefs to something like long int's on 32-bit systems and long long int's on 64-bit systems. Use those types where appropriate since you can't be sure they are compatible with other built in types if you want to be portable for both 32-bit and 64-bit systems.

  3. #3
    Registered User
    Join Date
    May 2007
    Posts
    45

    Talking

    Quote Originally Posted by MacGyver View Post
    Off the top of my head, for C I remember the following:

    • stdio.h
    • stdlib.h
    • malloc.h
    • string.h
    • ctype.h
    • limits.h


    The most important ones for basic things are stdio.h, stdlib.h, and string.h.

    FILE is just a struct of some sort. Types like size_t are usually typedefs to something like long int's on 32-bit systems and long long int's on 64-bit systems. Use those types where appropriate since you can't be sure they are compatible with other built in types if you want to be portable for both 32-bit and 64-bit systems.
    Ok thanks (=
    lol, I was half expecting someone to say I would need to memorize everything.

    A struct you say (=, Ok I will have to learn about them now then. Thank you for responding.

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by MacGyver View Post
    Off the top of my head, for C I remember the following:

    • stdio.h
    • stdlib.h
    • malloc.h
    • string.h
    • ctype.h
    • limits.h
    That one isn't standard.

    Ravens'sWrath: I'd say all of them -- but pace yourself. I am.

    [edit]And...
    Quote Originally Posted by MacGyver View Post
    FILE is just a struct of some sort. Types like size_t
    [Again to OP]...types such as FILE or size_t are opaque. You are intentionally not supposed to look up the skirt of the implementation. Partial details may be given, but you're not supposed to place emphasis on them.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  5. #5
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Quote Originally Posted by Dave_Sinkula View Post
    That one isn't standard.
    Good point. If it exists, stdlib.h includes it, I believe.

  6. #6
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    I never memorize... F1+msdn
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  7. #7
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by vart View Post
    I never memorize... F1+msdn
    Is the new MSDN better about documenting when and where it wanders off the standards? It seems to me some recent visits have shown this, but the old version(s) I don't remember as being as well done.

    [edit]And I can't memorize anymore either. I just make a lot of mistakes.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  8. #8
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by Dave_Sinkula View Post
    Is the new MSDN better about documenting when and where it wanders off the standards? It seems to me some recent visits have shown this, but the old version(s) I don't remember as being as well done.

    [edit]And I can't memorize anymore either. I just make a lot of mistakes.
    I don't know... I use Oct 2001 offline issue

    Code:
    strlen, wcslen, _mbslen, _mbstrlen
    Get the length of a string.
    
    size_t strlen( const char *string );
    
    size_t wcslen( const wchar_t *string );
    
    size_t _mbslen( const unsigned char *string );
    
    size_t _mbstrlen( const char *string );
    
    Routine                  Required Header                   Compatibility 
    strlen                     <string.h>                              ANSI, Win 95, Win NT 
    wcslen                   <string.h> or <wchar.h>        ANSI, Win 95, Win NT 
    _mbslen                 <mbstring.h>                         Win 95, Win NT 
    _mbstrlen               <stdlib.h>                              Win 95, Win NT
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  9. #9
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Wow, MSDN certainly doesn't look like that anymore. Now it's just bloated with .NET stuff and it's very hard to find what your looking for.

  10. #10
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by zacs7 View Post
    Wow, MSDN certainly doesn't look like that anymore. Now it's just bloated with .NET stuff and it's very hard to find what your looking for.
    Wll of course you have to use Google to search it instead of MS's own search.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  11. #11
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Quote Originally Posted by Dave_Sinkula View Post
    [edit]And I can't memorize anymore either. I just make a lot of mistakes.
    I can't even always remember the order of parameters for functions like memset().

    At 4:00am or so, I'm sitting and trying to remember which argument is the second one and which one is the third.

    Quote Originally Posted by Dave_Sinkula View Post
    Wll of course you have to use Google to search it instead of MS's own search.
    LOL. So true, it's funny.

    I'm sure that's quite commonly noticed. Way to really find something on MSDN is to query the function name in google with "MSDN" somewhere in the search string.

  12. #12
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Do Microsoft plan on replacing Win32 with .NET? Cause it certainly seems that way. Native Win32 controls are being overtaken with .NET controls, and the Win32API is being masked by .NETs API.

  13. #13
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by Dave_Sinkula View Post
    Wll of course you have to use Google to search it instead of MS's own search.

    MS search in the online version is killing me... Even when I enter some english phrase it tries to bring results in Russian only (partly understandable) or in French - no excuse at all... brrrr...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  14. #14
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    I can't even always remember the order of parameters for functions like memset().
    VisualAssist will do it for you
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  15. #15
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    I'm sure that's quite commonly noticed. Way to really find something on MSDN is to query the function name in google with "MSDN" somewhere in the search string.
    In google you can narrow your search to some domain...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. why doesnt the C++ standard library committee offer any AUI related libararie?
    By Masterx in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 02-13-2009, 01:48 PM
  2. Links to learn standard C library functions...
    By Nutshell in forum C Programming
    Replies: 8
    Last Post: 02-01-2002, 12:41 AM
  3. Source code of the standard library functions...
    By Nutshell in forum C Programming
    Replies: 2
    Last Post: 01-21-2002, 12:35 PM
  4. C standard library
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 12-08-2001, 12:08 PM
  5. Difference between library and headers
    By ripper079 in forum C++ Programming
    Replies: 1
    Last Post: 11-20-2001, 09:16 AM