Skip to content

Commit 86ee74a

Browse files
authored
Update C_syntax.md
Added content explaining functions
1 parent 941683c commit 86ee74a

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

LearningC/C_Language_Shorts/C_syntax.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ You can only use variables you previously declared (or included from other files
2323
## Variable Types
2424

2525
### Numbers:
26+
> [!NOTE]
2627
> **bool** `#include <stdbool.h>`:
2728
> > true or false
2829
>
@@ -45,15 +46,17 @@ You can only use variables you previously declared (or included from other files
4546
> > double precision real number (16-bit?)
4647
>
4748
48-
> [!NOTE]
49-
> For **intergers** we specify the size explicitly when it matters:
49+
> [!TIP]
50+
> For **intergers** we specify the size explicitly when it matters `#include <stdint.h>`:
5051
> - uint8_t : unsigned 8 bit
5152
> - int32_t : signed 32 bit
53+
>
5254
5355
### Arrays
5456
Records of homogenous data. Technically it's like a **list**\
55-
The classic example would be ** char* argv[] **\
56-
which holds the list of parameters/arguments passed to a program,
57+
The classic example would be **char\* argv[]**\
58+
which holds the list of parameters/arguments passed to a program.
59+
5760
### Struct
5861
When we need several variables to describe an entitiy. we use **struct** (records of heterogenous data)
5962

@@ -62,6 +65,10 @@ Sometimes we need alternatives. A **union** could consist of a number and the te
6265

6366
### Type defined
6467
You can define your own types with **_typedef_**
68+
```
69+
typedef uint16_t banana;//0-65535
70+
banaba bigNum = 1329:
71+
```
6572

6673
### Other/Any
6774
void: no variable/value
@@ -84,6 +91,22 @@ If you want to know how many bits they are, you can call the _sizeof() function_
8491
</details>
8592

8693
## Functions
94+
Functions have a **prototype** which defines parameters and return value.
95+
When you want to create a function you put the prototype at the beginning of the [source file](C_Files.md#source) or in the [header file](C_Files.md#header)
96+
> [!NOTE]
97+
> **prototype**
98+
> ```
99+
> <return-type> <function-name> (<arguments>);
100+
> ```
101+
>
102+
> **declaration**
103+
> ```
104+
> <return-type> <function-name> (<arguments>){
105+
> <function-body>
106+
> return <return-value>;
107+
> }
108+
> ```
109+
>
87110
88111
## Conditional
89112

0 commit comments

Comments
 (0)