Changes between Initial Version and Version 1 of ResumedC


Ignore:
Timestamp:
Mar 31, 2009, 3:32:30 AM (16 years ago)
Author:
Thanatermesis
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ResumedC

    v1 v1  
     1
     2== Comments ==
     3
     4The 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 variables
     5
     6It 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 comments
     7
     8The special things that you need to have in mind when you code is: clarity of code, simplicity, and summary
     9
     10
     11== Basic Things ==
     12
     13To declare a string in a variable, you need to use strcpy, so
     14{{{
     15   name = "Me";   /* Illegal */
     16   strcpy (name, "Me");    /* Legal */
     17}}}
     18
     19When you assign a single character you need to enclose it in single-quotes ', if you want to assign a string (with the end-of-string (NULL) char included), you need to use double-quotes ".
     20
     21
     22A good way to remove the newline value from variables (when you use a input-line entry system) is by simply set the end-of-string (NULL) value to the newline place, like:
     23{{{
     24#!C
     25   fgets(first, sizeof(first), stdin);
     26   first[strlen(first)-1] = '\0';
     27}}}
     28Remember that a string contains first a newline (if the input has included a newline) and all the strings finishes by the '\0' (NULL) character
     29
     30== Arrays ==
     31
     32A two dimensional matrix looks like:
     33{{{
     34#!C
     35   mtrx_var[2][4];
     36}}}
     37
     38Notice that this form is illegal:
     39{{{
     40#!C
     41   mtrx_var[2,4];
     42}}}
     43
     44This is also valid:
     45{{{
     46#!C
     47   int mtrx_var[2][4] =
     48       {
     49          {1, 2, 3, 4},
     50          {10, 20, 30, 40}
     51       };
     52}}}
     53
     54
     55== Variables ==
     56
     57signed: 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'''
     58
     59The '''constant''' variables are constants, so they can't change, by convention they are in upper-case
     60