April 14th, 2013, 09:25 PM
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.
April 18th, 2013, 03:19 PM
My local.h includes
You should be familiar with a great many standard functions and definitions. Using them will reduce the amount of code you duplicate poorly.
[/code] are essential for python code and Makefiles!
April 18th, 2013, 04:21 PM
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.
April 18th, 2013, 04:35 PM
I'm sure I learned a good deal about programming by reading through Software Tools fairly carefully.
[/code] are essential for python code and Makefiles!
April 18th, 2013, 04:51 PM
April 18th, 2013, 04:54 PM
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.
Originally Posted by miz6565
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 04:58 PM.
April 18th, 2013, 05:03 PM
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 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.
April 23rd, 2013, 06:30 AM