From 52f5effca30b476b427c2d3a7518c91c0e292fa4 Mon Sep 17 00:00:00 2001 From: Silvino Silva Date: Wed, 7 Mar 2018 22:33:00 +0000 Subject: dev c datatypes initial document --- dev/c/datatypes.html | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++- dev/index.html | 2 +- 2 files changed, 107 insertions(+), 2 deletions(-) diff --git a/dev/c/datatypes.html b/dev/c/datatypes.html index 6d6b76d..a149c24 100644 --- a/dev/c/datatypes.html +++ b/dev/c/datatypes.html @@ -12,12 +12,117 @@

Data types

Integer

+

Allowed types are char and int;

+
+
signed char
+
8 bit, from -128 to 127.
+
unsigned char
+
8 bit, from 0 to 255.
+
char
+
8 bit, used to store ASCII, ex; 'h', '\n', etc...
+
short int
+
16 bit, from -32,768 to 32,767.
+
unsigned short int
+
16 bit, from 0 to 65,535.
+
int
+
32 bit, from -2,147,483,648 to 2,147,483,647.
+
unsigned int
+
32 bit, from 0 to 4,294,967,295.
+
long int
+
32 bit, from -2,147,483,648 to 2,147,483,647.
+
unsigned long int
+
32 bit, from 0 to 4,294,967,295.
+
long long int
+
64 bit, from 9,223,372,036,854,775,808 + to 9,223,372,036,854,775,807.
+
unsigned long long int
+
64 bit, from 0 to 18,446,744,073,709,551,615.
+
+

Real number

+ +

Real numbers are fractional numbers, all floating points + are signed. Check float.h.

+ +
+
float
+
From 1e-37 to 1e37
+
double
+
Largest of floating point.
+
long double
+
The long double data maybe larger than double
+
+

Complex number

-

Enumeration

+ +

Complex Number Types

+ +

Enumeration

+ +
+        enum colors {black, orange, blue} color;
+        enum colors color;
+        
+

Unions

+ +
+        union accounts {
+            int id;
+            float value;
+        } first_account, second_account;
+        
+

Structures

+ +
+        struct point {
+            int x, y;
+        } first_point;
+        struct point second_point;
+        
+

Arrays

+ +
+        int account_array[9];
+        int account_array[] = {0, 1, 2, 3};
+        int account_array[] = {0, 1, 2, [9] = 9};
+        
+ +
+        int account_array[2][9] { {1,2,3},{9,8,7} }
+        
+ +

Initializing string with individual characters the + null character must be defined;

+ +
+        char black[] = {'b', 'l', 'a', 'c', 'k', '\0'}
+        
+ +
+        char black[] = "black";
+        
+ +
+        union accounts {
+            int id;
+            float value;
+        };
+        union accounts accounts_array[9];
+        accounts_array[0].id = 8;
+        
+ +
+        struct point {
+            int x, y;
+        };
+        struct point point_array[9];
+        point_array[0].x=2;
+        point_array[0].y=3;
+        
+

Pointers

Incomplete types

Type qualifiers

diff --git a/dev/index.html b/dev/index.html index d84fa36..afd147e 100644 --- a/dev/index.html +++ b/dev/index.html @@ -62,7 +62,7 @@
  • Integer
  • Real number
  • Complex number
  • -
  • Enumeration
  • +
  • Enumeration
  • Unions
  • Structures
  • Arrays
  • -- cgit 1.4.1-2-gfad0