Chapter Summary Q Flashcards
1: What is applications programming?
Programming of software to provide services for the user directly
1: What is systems programming?
Programming of software that provides services for other software or for the underlying computer system
3: What is a pointer?
It is a variable to store a memory address of another variable. They can be 4-8 bytes, and allow for Pass-by-reference.
Note that multiple pointers can point to the same address.
3: What are two possible errors associated with pointers?
Segmentation fault/NULL Pointer: A pointer is pointing to NULL, crashes program.
Dangling Pointer: Pointer is pointing to random data (cruft data), will cause strange behavior and is difficult to find.
3: How does a pointer to a array work?
A pointer to a array typically points to the first element of the array. As such the following is technically a pointer:
EXAMPLE: int AR[30] = { ------ } AR; //AR = pointer to AR[0] //Also means: AR == &AR[0]; AR+2 == AR[2];
3: How does adding to arrays to increment work?
*AR+4 == AR[0]+4 //So the VALUE at [0] has been incremented by 4
vs.
*(AR+4) == AR[4]
1: What are some things that the OS provides?
File I/O Device I/O Process Managements Virtual Memory Scheduling
1: What is a shell?
A command line user interface for accessing the OS
1: What are the three major Unix shells?
sh : bourne shell
bash: bourne again shell
csh: c shell
3: What are command line arguments and how are they used?
A command line argument is a variable inputed into a function/program from the command line b doing: ./program val1 val2 … valn
They are recieved in the programs main by: int main(int argv, char *argc[]) {.....}
Where: argv = number of cmd-line inputs
argc = the string/character array
1: What is a compiler?
Computer software that transforms source code written in one programming language into another
3: What does the size command do?
size results in a output of:
text = Text segment data = Init data size bss = Unit data size dec = sum of text+data+bss in base 10 hex = same as dec but in base 16 filename = name of .exe
1: What is the basic format for formatting variables with printf
%[flags][width][.precision][length]
1: What is the path from source code to a running program?
.c source file --compile .o object file --link executable file --run program is running!
3: What is stack overflow?
It is a error which occurs when a repeating function call occurs which depletes all free memory and fills the stack
1: What is the basic format for formatting variables with printf
%[flags][width][.precision][length]
3: How does adding to arrays to increment work?
*AR+4 == AR[0]+4 //So the VALUE at [0] has been incremented by 4
vs.
*(AR+4) == AR[4]
1: When formatting with %_, which characters denote:
- an integer?
- an unsigned integer?
- a float with 6 decimal precision?
- a float with exponential precision?
Integer: %d
Unsigned Int: %u
Float with 6 dec.: %f
Float with exp. prec.: %g
1: When formatting with %_, which characters denote:
- a char?
- a string?
- a hexadecimal?
- an octal?
Char: %c
String: %s
Hexa: %x
Octal: %o
1: How does the precision modifier affect the format when applied to:
- a float
- an exp. float
- a string
- %d, %u, %o, %x, %X
- float: precision is how many decimal places
- exp. float: precision is how many digits total
- string: precision is how many characters displayed
- how many leading zeroes are shown
1: What does the “continue” command do?
skip the current item in a for loop and go on to the next item
1: How do you define a constant in C?
define DAYS_IN_YEAR 365
3: If a dynamically allocated variable was modified how would you allocate it and free it?
//Allocate int *a; int *aTemp; a = aTemp = malloc(sizeof(int));
//Free
free(aTemp);
free(a);
1: What does the “break” command do?
break out of the current innermost loop