User Tools

Site Tools


cplusplus:c_versus_cplusplus

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
cplusplus:c_versus_cplusplus [2020/05/04 01:27] – [Defining variables] mithatcplusplus:c_versus_cplusplus [2020/05/04 01:40] (current) – [C Examples] mithat
Line 78: Line 78:
     int a,b,c;     int a,b,c;
     float x,y,z;     float x,y,z;
 +    
     ...     ...
 } }
 </code> </code>
-  * In older versions of C, you //must// define variables at the beginning of a function.+  * In older versions of C, you must define all variables at the beginning of a function.
   * Common practice today anyway.   * Common practice today anyway.
 ===== Prototypes ===== ===== Prototypes =====
Line 102: Line 103:
   * Best practice to use them anyway.   * Best practice to use them anyway.
 ===== Named constants and macros ===== ===== Named constants and macros =====
-  * ''const'' is available only in newer versions of C.+  * ''const'' modifier is available only in newer versions of C.
   * ''#define'' preprocessor directive typically used instead.<code c>   * ''#define'' preprocessor directive typically used instead.<code c>
 #define PI 3.1415 #define PI 3.1415
Line 118: Line 119:
 myDouble = (double)myInt/3;  /* cast myInt to a double */ myDouble = (double)myInt/3;  /* cast myInt to a double */
 </code> </code>
-  * No ''static_cast<>'', etc. 
   * Place the type you want a value cast to inside parenthesis before the value.   * Place the type you want a value cast to inside parenthesis before the value.
 +  * No ''static_cast<>'', etc.
 +
 ===== Dynamic memory ===== ===== Dynamic memory =====
   * Use ''malloc()'' and ''free()''.   * Use ''malloc()'' and ''free()''.
Line 155: Line 157:
 ===== Some C Resources ===== ===== Some C Resources =====
  
-  * [[https://www.math.brown.edu/~jhs/ReferenceCards/CRefCard.v2.2.pdf|C Reference Card (ANSI)]] +  * [[https://www.math.brown.edu/~jhs/ReferenceCards/CRefCard.v2.2.pdf|C Reference Card (ANSI)]] Highly recommended! 
-  * [[http://www.tutorialspoint.com/cprogramming/|C Tutorial]] from Tutorials Point+  * [[C examples|C code examples]] 
  
-===== C Examples ===== 
-  * Look [[C examples|here]]. 
cplusplus/c_versus_cplusplus.1588555659.txt.gz · Last modified: 2020/05/04 01:27 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki