#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    101
    Rep Power
    0

    All to know about C


    I know there's many many many concepts to know about C but can I ask, do you need to know all the header files in detail and there functions? I'm just asking for input if you C programmers tend to know everything (almost) about C.

    Thanks again, don't know why but it's been in my head when it's not even a big deal.
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,995
    Rep Power
    481
    My local.h includes

    #include<sys/types.h>
    #include<sys/stat.h>
    #include<pthread.h>
    #include<assert.h>
    #include<stdarg.h>
    #include<string.h>
    #include<unistd.h>
    #include<stdlib.h>
    #include<limits.h>
    #include<ctype.h>
    #include<fcntl.h>
    #include<stdio.h>
    #include<math.h>

    You should be familiar with a great many standard functions and definitions. Using them will reduce the amount of code you duplicate poorly.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Location
    Scotland
    Posts
    6
    Rep Power
    0
    Now that we're on this question, in which order would you suggest learning them / in which order did you learn them?

    Thanks for your time.
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,995
    Rep Power
    481
    #include<string.h>
    #include<stdlib.h>
    #include<ctype.h>
    #include<stdio.h>
    #include<math.h>

    I'm sure I learned a good deal about programming by reading through Software Tools fairly carefully.
    [code]Code tags[/code] are essential for python code and Makefiles!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Location
    Scotland
    Posts
    6
    Rep Power
    0
    http://www.amazon.com/Software-Tools-Brian-W-Kernighan/dp/020103669X ?
  10. #6
  11. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,117
    Rep Power
    1803
    Originally Posted by miz6565
    I know there's many many many concepts to know about C
    I would not go that far; C is a very small and simple language. The standard library is a distinct entity from the language itself.

    The C standard library is not that large. You would do well to t least survey it so that you know what it contains so that you are reinventing the wheel writing code that already exists.

    You do not need to learn all the interfaces because they are all well documented; I still look-up a reference to printf() from time-to-time when I need some particularly specific format specifier. But you do need to learn what facilities exist in order to know what to look up when you need it.

    That is just the standard library. There are any number of third-party, higher-level, and OS API libraries, so obviously you are not going to be able to "learn" them all much less use them.

    You might start here: http://www.cplusplus.com/reference/clibrary/
    Last edited by clifford; April 18th, 2013 at 05:58 PM.
  12. #7
  13. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,255
    Rep Power
    2222
    Think of learning a human foreign language. Should you know that language's entire vocabulary? Certainly. Can you learn that all at once? No. In what order should we learn the words; ie, which words should we learn first, then second, etc? That depends on your learning materials and your needs. If you're learning from a book, then that question has been answered for you. The textbook author should have made her decisions based on which words are more frequently used as well as basic terminology for the variety of "life in that country" scenarios that will be the subject of the dialogues and reading selections that start each chapter (eg, arriving in the country by train or plane, navigating the city and asking directions, using public conveyance, shopping in a store and/or grocery, ordering a meal in restaurant). Furthermore, if the student wants to use the language to discuss specific types of activities, such as programming, then he will want to familiarize himself with that activity's specialized terminology. So that short answer would be: that all depends on what you're going to use the language for.

    Now how does that apply to learning the C standard library? It's pretty much the same. You will need to learn the functions that you will need to do the things that you want to do in the language; eg, if you want to do multi-threading under UNIX/Linux, then you will learn the functions in pthread.h, but if you're not going to do that then you won't learn them. If you're going to work with time, then there's time.h, but if you're not going to work with time, then you won't learn those functions.

    Of course, some functions are very commonly used. Do you plan to read input from a keyboard and display output on the screen? Who wouldn't? Well, embedded programmers whose hardware doesn't have a console wouldn't, but most C programmers would. Well then you will need to learn I/O functions in stdio.h. You will also need to learn functions in stdio.h if you're going to be doing file I/O. Are you going to work with strings? Again, who wouldn't? Well then you will learn from string.h. Going to use dynamic memory allocation/deallocation? malloc.h, though they're also defined in stdlib.h. Random number functions are also in stdlib.h, as are functions to convert numeric strings to values. Going to do calculations? math.h Going to have to test what kind of characters you're processing (ie, is it a letter, digit, punctuation mark?)? ctype.h

    And if you're learning from a textbook, then the author has already made this decision for you.

    Basically, you will learn the functions that you need as you need them, though reviewing what's in each header file will help make you aware of what's available. Every time you need to use a function, read or review its documentation, which you will either find in the textbook, in a help file that came with the compiler, or in that function's man page (thousands of versions of the man pages are on-line; Google on man page function-name). That documentation will tell you what the function does, what its syntax is (ie, what arguments to pass it), what its return type is, what its return values mean, what related functions are, and basically how to use it and behavior you should be aware of. Do not hesitate to return to a function's documentation in order to review it. And pay especial attention to what the return values mean; eg, hardly anybody ever uses scanf's return value, but it can prove absolutely essential at times.

    in which order would you suggest learning them / in which order did you learn them?
    In case the answer was lost in that explanation: You learn them as you use them and the order in which you need to use them will be the order in which you learn them. And quite naturally the most frequently used functions will be among the first that you learn.

    The only real trick is in realizing that there's a function that can solve a problem you're working. For that, you can ask another programmer what function that would be, at which point your next action will be to read that function's documentation.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    1
    Rep Power
    0
    #include<string.h>
    #include<stdlib.h>
    #include<ctype.h>
    #include<stdio.h> :)

IMN logo majestic logo threadwatch logo seochat tools logo