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
Last revisionBoth sides next revision
cplusplus:c_versus_cplusplus [2020/05/04 01:26] – [Casting] mithatcplusplus:c_versus_cplusplus [2020/05/04 01:40] – [Some C Resources] 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 101: 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 117: 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 133: Line 136:
  
 ===== Structs ===== ===== Structs =====
-  * Only member variables are allowed. 
-    * No member functions. 
-  * Everything is public. 
-    * No access specifiers. 
-  * You must use the ''struct'' keyword when defining ''struct'' variables. 
- 
 <code c> <code c>
 struct MyStruct struct MyStruct
Line 148: Line 145:
 struct MyStruct aStructInstance;  /* requires struct keyword */ struct MyStruct aStructInstance;  /* requires struct keyword */
 </code> </code>
 +  * Only member variables are allowed.
 +    * No member functions.
 +  * Everything is public.
 +    * No access specifiers.
 +  * You must use the ''struct'' keyword when defining ''struct'' variables.
 +
 +
  
 ===== Classes ===== ===== Classes =====
Line 153: 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 ===== ===== C Examples =====
   * Look [[C examples|here]].   * Look [[C examples|here]].
cplusplus/c_versus_cplusplus.txt · Last modified: 2020/05/04 01:40 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki