mirror of
https://github.com/m-lamonaca/dev-notes.git
synced 2025-04-08 03:46:41 +00:00
Compare commits
No commits in common. "d872337de436300faf68d657f65acdde3891206e" and "0f4b290330fdacce27e11b1f4b346353da8ef358" have entirely different histories.
d872337de4
...
0f4b290330
1 changed files with 14 additions and 12 deletions
|
@ -316,6 +316,13 @@ string.c_str(); //reads string char by char
|
||||||
string.find(substring); // The zero-based index of the first character in string object that matches the requested substring or characters
|
string.find(substring); // The zero-based index of the first character in string object that matches the requested substring or characters
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Vectors
|
||||||
|
|
||||||
|
```c
|
||||||
|
#include <vector>
|
||||||
|
vector<type> vector_name = {values}; //variable length array
|
||||||
|
```
|
||||||
|
|
||||||
## Decision Statements
|
## Decision Statements
|
||||||
|
|
||||||
### If Statements
|
### If Statements
|
||||||
|
@ -395,20 +402,15 @@ It is possible to declare functions **after** the main only if the *prototype* i
|
||||||
To return multiple variables those variables can be passed by reference so that their values is adjourned in the main.
|
To return multiple variables those variables can be passed by reference so that their values is adjourned in the main.
|
||||||
|
|
||||||
```c
|
```c
|
||||||
// function prototype (usually in a .h file)
|
type function_name(type argument1, ...); // function prototype
|
||||||
type function_name(type argument1, ...);
|
|
||||||
|
|
||||||
// function implementation (usually in a .c file)
|
type functionName (parameters) {
|
||||||
type function_name (parameters) {
|
|
||||||
return <expression>;
|
return <expression>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// function without a return value
|
void functionName (parameters) { }
|
||||||
void function_name (parameters) { }
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> **Note**: annotatic a function with `static` makes it visible only inside the file in which is implemented/declared
|
|
||||||
|
|
||||||
### Arguments passed by reference without pointers
|
### Arguments passed by reference without pointers
|
||||||
|
|
||||||
Passing arguments by reference causes modifications made inside the function to be propagated to the values outside.
|
Passing arguments by reference causes modifications made inside the function to be propagated to the values outside.
|
||||||
|
@ -419,10 +421,10 @@ type functionName (type &argument1, ...) {
|
||||||
//code here
|
//code here
|
||||||
return <expression>;
|
return <expression>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function_name (argument_1, ...);
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
`functionName (arguments);`
|
||||||
|
|
||||||
### Arguments passed by reference with pointers
|
### Arguments passed by reference with pointers
|
||||||
|
|
||||||
Passing arguments by reference causes modifications made inside the function to be propagated to the values outside.
|
Passing arguments by reference causes modifications made inside the function to be propagated to the values outside.
|
||||||
|
@ -433,10 +435,10 @@ type function_name (type *argument_1, ...) {
|
||||||
instructions;
|
instructions;
|
||||||
return <expression>;
|
return <expression>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function_name (&argument_1, ...);
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
`function_name (&argument_1, ...);`
|
||||||
|
|
||||||
## Arrays
|
## Arrays
|
||||||
|
|
||||||
```c
|
```c
|
||||||
|
|
Loading…
Add table
Reference in a new issue