Changes between Version 17 and Version 18 of ResumedC
- Timestamp:
- May 17, 2009, 10:55:30 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ResumedC
v17 v18 1 1 [[TOC]] 2 2 3 ,,'''Note''': This is not pretended to be a Howto, also not really ''public'', it is just a page that i have used to take some notes of a interesting book of C that im reading, you are allowed to edit and correct this document if you see anything wrong, also order it a bit or made it better, but this not pretendsto be a ''big'' document so try to maintain it compact. Thanks,,3 ,,'''Note''': This is not pretended to be a Howto, also not really ''public'', it is only a page that I have used to take some notes of an interesting book of C that I'm reading. You are allowed to edit and correct this document if you see anything wrong, also order it a bit or make it better, but this not pretended to be a ''big'' document so try to maintain it compact. Thanks,, 4 4 ---- 5 5 … … 8 8 === Comments === 9 9 10 The comments are very important for yourself basically, you need to comment all your functions and declarations, and specially you need to comment your variables in order to know *what* exactly they are, and also for know possible special things of these variables11 12 It is recommended to learn how works '''doxygen''' (5 minutes reading a howto in google, it is very basic) so that you can know special techniques to comment your source code that then you can build''documentation'' of your API/source directly from these comments10 The comments are very important for yourself. Basically, you need to comment all your functions and declarations and especially your variables in order to know *what* exactly they are and to remember the special things about these variables. 11 12 It is recommended to learn how '''doxygen''' works (5 minutes reading a howto in google, it is very basic) so that you know special techniques about commenting your source code. This will aid in build proper ''documentation'' of your API/source directly from these comments 13 13 14 14 The special things that you need to have in mind when you code is: clarity of code, simplicity, and summary … … 57 57 if (var == 0) 58 58 }}} 59 ,,Maybe this sounds strange by doing this on this way, but if ''var'' is equal to 0, then the result of the '''()''' is 1 (true), if you don't understand why is 1 or how this works, you need to start reading a new book of C again.,,59 ,,Maybe this sounds strange by doing it this way but if ''var'' is equal to 0, then the result of the '''()''' is 1 (true), if you don't understand why is 1 or how this works, you need to start reading a new book of C again...,, 60 60 61 61 … … 86 86 }}} 87 87 88 The ''counters'' of the arrays start by 0, so if you need to create an array of 4 elements you need to declare 4 and use them from 0 to 3, this may besound strange:88 The ''counters'' of the arrays start by 0, so if you need to create an array of 4 elements you need to declare 4 and use them from 0 to 3, this may sound strange: 89 89 * This maybe sound strange, like ''why i need to declare 4 then instead of 3 ?'': simple, because you are declaring 4, and you still having 4 (0 to 3 = 4) 90 90 … … 99 99 If you need a ''Global variable''' in your entire code, you need to declare them out of any function 100 100 101 Every time you enclose a variable declaration inside a block '''{}''', it is limited to this section (not works out of it), if you have variables declared out of any function and/or out of main(), it is supported by all the entire application. Also, if you declare a variable inside a block that is already declared outside of it, then for inside the block it is used only the new declared one, not the one declared out of it, however, this practice is not good since may be very confusing.101 Every time you enclose a variable declaration inside a block '''{}''', it is limited to this section (will not work outside of it). If you have variables declared out of any function and/or out of main(), it is supported by all the entire application. Also, if you declare a variable inside a block that is already declared outside of it, then for inside the block it is used only the new declared one, not the one declared out of it, however, this practice is not good since may be very confusing. 102 102 103 103 '''signed''': means ''with sign'', so, values negative and positive, for example if the '''char''' variable has a limit of 255 values, using the '''sign''' mode we can use from '''-128''' (negative) to '''127''' (positive), and using '''unsigned''' we can use from '''0''' to '''255''' … … 107 107 108 108 ==== Static ==== 109 You can use ''static'' inside a function or outside it, it has two different smeanings:109 You can use ''static'' inside a function or outside it, it has two different meanings: 110 110 * Inside a function: You can ''pre'' set a value to a variable ''(static int foo = 5)'', then the first time you enter on the function it will be set to 5, but the next times it not set again, it just remember the last value used 111 111 * Outside a function (global mode): You will use it only in the actual file (compilation unit), good for optimization but you can't use it on other files … … 278 278 279 279 ==== Double pointers ==== 280 The double pointer can be used for 2 different sthings:280 The double pointer can be used for 2 different things: 281 281 * A pointer that points to a pointer, so that you can change the value of the original pointer (address value) 282 282 * ''To modify the value of a variable using pointers in a function, you need to pass the address of that variable'': Same thing when you try to modify the address of a pointer (pointer of a pointer) … … 406 406 * The book of C by Kernighan & Ritchie 407 407 * Practical C Programming (very good to understand correctly C and do good practices on it) in o'reilly 408 * Mastering C Algorithms (advanced C) in o'reilly408 * Mastering C Algorithms (advanced C) in O'Reilly 409 409 410 410 == References ==