Skip to content
Snippets Groups Projects
Commit c7f6f04a authored by Mactavish's avatar Mactavish
Browse files

update

parent 2a91e940
Branches
No related tags found
No related merge requests found
...@@ -197,4 +197,38 @@ int main() { ...@@ -197,4 +197,38 @@ int main() {
This list goes on, you can find more information about undefined behaviours in this [thesis](https://solidsands.com/wp-content/uploads/Master_Thesis_Vasileios_GemistosFinal.pdf) and in the [C99 Standard](https://www.dii.uchile.cl/~daespino/files/Iso_C_1999_definition.pdf) This list goes on, you can find more information about undefined behaviours in this [thesis](https://solidsands.com/wp-content/uploads/Master_Thesis_Vasileios_GemistosFinal.pdf) and in the [C99 Standard](https://www.dii.uchile.cl/~daespino/files/Iso_C_1999_definition.pdf)
## Memory Model in C ## True or False
There is no explicit `Boolean` type in old-school C. Alternatively, you can use the boolean type in the header file `#include <stdbool.h>` introduced in `C99`.
```c
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int main(void) {
bool keep_going = true; // Could also be `bool keep_going = 1;`
while(keep_going) {
printf("This will run as long as keep_going is true.\n");
keep_going = false; // Could also be `keep_going = 0;`
}
printf("Stopping!\n");
return EXIT_SUCCESS;
}
```
### What evaluates to FALSE in C?
- `0` (integer)
- `NULL`
- Basically anything where all the bits are 0 is false
### What evaluates to TRUE in C?
- Anything that isn't false is true
## Pointers in C
Pointers are probably the single largest source of bugs in C, so be careful when you use them.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment