Starting Flashcards
Which are the 2 compilers used for C?
gcc and clang
How to compile a file world.c in gcc?
gcc world.c -std =c90
what are the different gcc compiler options and what are their uses?
The different gcc compiler options are
- -o: Name your executable
- -g: Add in debugging information
- -Wall: Give warnings
- -Wextra: Give additional warnings
- -O, O2, O3: Compiler optimization and different levels of it.
What are the 2 stage compilation for gcc?
Compilation using the -c flag
Linking using the -o flag
What is the size of char and is it implementation dependent?
The size of char on any computer will be 8bits
What is the range of signed and unsigned chars
Unsigned chars: {0…255}
Signed chars: {-128….127}
What is the order of the size of the types?
Which all data types are signed/unsigned by default?
The order is as follows
char < short < int < long < long long
Every type is signed by default except for chars
What variables are initialized to 0.
Only global variables are initialized to 0
What are print modifiers for float, shortest of %f,%e
float: %f
shortest of %f, %e: %g
Print modifiers for hex, octal, long int and double
Hex: %x,
Octal: %o
long int: %li
double: %lf
What to watch out for when using the print function:
The compilers don’t check to see if the number of type modifiers is equal to the number of arguments to be output.
Precedence of operators
- Assignment is the lowest
- * / % are all equal
- relational operators > == and !=
- ++–(cast) this is evaluated from left to right
- addition and subtraction > relational operators
What is #include
How to include a library header file?
include <curl></curl>
it is preprocessor directive. These are used to insert header files into the program. These header files are given the extension .h
What is the scanf function?
The scanf function is used to read in input. It only contains conversion specifications
What are the things to watch out for when using scanf?
- The programmer must make sure that the number of input specifiers matches the number of arguments
- The & symbol precedes the name of the variable and the programmer must make sure that this is included.
- Scanf also peeks at the final new line without reading it