Lecture 2 - C Basics Flashcards
Is C object-oriented?
No
What is the difference between Java and C when OOP is ignored?
How memory is managed and how the program is executed.
What does -Werror do?
Turns all warnings into errors making the program impossible to compile until all warnings have been fixed.
What does the -Wall flag do?
The -Wall flag enables most compiler warnings
What are make files?
Files that allow building of C programs automatically -> with a command.
Are make files C exclusive?
No, they can be used for any command line interface command.
What is the first line of a make file made up of?
[targets] : [sources]
- sources can be thought of as dependencies
What does typing make in the CLI do?
Execute the first command in the make file.
What does every C program have ?
An entry function called main.
Do we need to return anything from a main function?
No, 0 is automatically returned by the function.
0 indicates successful execution
What does a non-negative value returned from main indicate?
unsuccessful execution
What are the 2 versions of main?
int main() { … }
int main(int argc, char* argv[]) { … }
What is a C programming language?
A statically typed language where every variable must have a data type known without running the program.
What are data types?
A label which gives meaning to its stored in memory.
What do we control when choosing a specific data type?
The amount of memory we use, as different data types take up different amount of space.
How do booleans work in C?
0 is false and anything else is true. The data type is int.
What do data types help with ?
Preserving meaning to computations and results.So only meaningful computations can be completed.
Size of char?
1 byte
Size of short / unsigned short?
2 bytes = 16 bits
Size of int / unsigned int?
4 bytes = 32 bits
Size of long / unsigned long?
4 or 8 bytes
Size of long long / unsigned long long?
8 bytes
What does the <stdbool.h> inclusion give us?</stdbool.h>
The ability to have a defined type of boolean (bool) in C99.
These are defined as macros
What is a {} called in C?
A block