midterm superdeck Flashcards
Range of a typical short int in C.
-2^15 to 2^15-1
This is 4 bytes.
-32768 to 32767
3 Components of a makefile.
target, dependency, recipe
Makefile, what determines if the recipe is performed?
The timestamp difference between the target and dependency. (I.e. If the dependency has changed, i.e. an extra file that hasn’t changed and doesn’t need to be recompiled).
Bash loop structure.
for condition
do
done
Bash if statement structure.
if
then
else
fi
How might one iterate through every file that starts with the command-line argument in bash?
for i in $1*
General command format
command -[options] [arg1] [arg2] … [argn]
What are the sources of input and output for commands?
stdin 0
stdout 1
stderr 2
These are 3 special files
Where does everything in Unix start?
The root (/).
What are the two main ways to get information about a command?
Using:
man command
or
command –help
cat command.
cat file
Takes input from file and puts it to stdout
Redirection in bash.
Output redirection
> overwrites a file
» appends a file
Input redirection
<
for example
command [arguments] < filename
How to type EOF in bash?
ctrl-d
echo command
Takes input (arguments) and puts it in stdout.
Bash comparison.
==, !=, <, etc for strings.
-eq, -ne, -lt, etc for math.
Bash else if.
if
then
elif
then
else
fi
What are the steps to the full process of building a file?
Preprocessor. Take definition, insert header files, make a program.
Compiler. Syntactically correct program translated into lower form (assembly).
Assembler. Translate assembly language statements into actual instructions. object code or .o file.
Linker. All object files linked together with system libraries to produce executable file.
all in a makefile.
all must be the first target.
Conventionally builds the entire project.
Has one dependency.
No recipe.
clean in a makefile.
Has no dependencies.
Conventionally removes everything made by the build process (executables and .o files)
What is .PHONY: used for?
This says that its dependencies, such as all and clean, are not real targets and do not produce files named after themselves.
Minimum size of int.
2 bytes. 16 bits.
Float and double format specifier.
%f, %e, and %g.
Booleans in C.
_Bool type (since C99 standard).
0 is false and 1 is true (or rather, anything other than 0 is true). false is 0, true is 1.
Making a long int literal.
A number followed by ‘L’. For example, making a long int of 2024 is
2024L
Such as
long int x = 2024L;