These are placeholders for contents of a variable typically used in a printf control stream.
Bonus: list four and explain what they represent
What are format specifiers?
%d: int, %f: float, %ld: long, %c: char, %s: string
(6 decimal digits by default)
This command allows you to change directories.
What is cd?
This is the difference between // , /*...*/, and #.
What is a single line comment, a multi-line comment, and a preprocessor directive / macro?
#include : preprocessor directive
#define: macro
These are the two steps you have to do before running a C program.
What is compiling and linking?
1. Compile: translate human readable code -> machine language
2. Link: translate machine language -> executable
This Aggregate Data Type is a homogeneous collection of elements of some base type
What is an array?
These symbols represent hard to type / invisible characters.
Bonus: list four and explain what they represent
What are escape sequences?
\t: tab, \b: backspace, \": double quote, \\: backslash itself
This command gives you more info about a given command
What is man?
This is the return type of the main function in c, followed by what it returns and when.
What is int and 0 when successful or 1 when failure?
This is how you compile a source file (file.c) into an object file, including all of the flags mentioned in class.
Bonus: state what does each flag means
What is gcc -std=c99 -Wall -Wextra -pedantic -c file.c?
gcc: compiler, -std=c99: c99 standard, -Wall: all warnings, -Wextra: extra warnings, -pedantic: strict adherence to standard (picky about warnings), -c: compile source files but don't link
This Aggregate Data Type is a heterogenous collection of elements, referenced by name
What is a struct?
This tells the preprocessor to replace its name with its definition.
What is a macro? What is a preprocessor directive?
This command creates a new directory.
What is mkdir?
This is how you would print x (a variable of type int), y (a variable of type character), and z (a variable of type float) to standard out in c.
What is printf("x = %d, y = %c, z = %f", x, y, z); ?
This is how you link an object file to create an executable, including all of the flags mentioned in class.
Bonus: state what does each flag means
What is gcc -std=c99 ... -o file file.o?
gcc: compiler, -std=c99: c99 standard, -Wall: all warnings, -Wextra: extra warnings, -pedantic: strict adherence to standard (picky about warnings), -o: link flag to create executable, file: example executable name (if not given = a.out), file.o: example object file
This is the content of an uninitialized local variable.
What is unknown?
(global variables default to zero)
This keyword changes the accessibility of global variables and functions, and changes the persistence of local variables and functions.
What is static?
Global variables and functions: (accessibility) can only be called from the file it's currently in (source file)
Local variables and functions: (persistence) retain their value from the previous call
This command lists files and directories.
Bonus: name a flag associated with this command and explain what it does.
What is ls?
ls -l: long listing
ls -d: list directories not content
ls -s: print size of each file in blocks
This is the difference between “ “ and < > in regards to a header file.
What is a standard library (found where C is stored) versus a user defined library (found in current directory)?
This is how you compile and link in one step.
What is gcc -Wall -Wextra -std=c99 -pedantic file.c -o file?
This is used as an indicator of a memory address, a reference to something, or an "alias" for a parameter.
What is a pointer?
These are used to prevent variables / functions headers from being declared more than once.
What are header guards?
#ifndef TREE_H
#define TREE_H
...
#endif
Name a command to create a file (more than one right answer, bonus points for both)
These are the differences between a macro and a constant.
What is a direct substitution versus a variable that can't be modified?
Macro: #define [name] [value], preprocessor directive != a variable, direct substituition, stored in Text section
Constant: const [type] [name] = [value], const = modifier, tells compiler that variable cannot be changed, stored in Data, Stack, or Heap depending on how it's used
These are the four main stages that a C program goes through to become an executable. List all 4 and give a brief description of what happens during each stage.
Bonus: state what the file types are at each stage.
PCAL
1. Preprocessing: macro substitutions take place, comments removed, included files expanded (ex. stdio.h), .c file -> .i file
2. Compiling: compiler translates HLL into AL, .i file -> .s file
3. Assembling: assembler translates AL into ML, .s file -> .o file
4. Linking: linker links function calls with their definitions, standard libraries needed to run programs = expanded into executables, .o file -> executable
This is a list of all of the program segments in memory, also known as the process address space (in order).
What is the text section (executable code), data section (initialized global data), bss (uninitialized global data), heap (storage allocation), and stack (function calls and return locations)?