CIS*2750: Midterm Questions and Correct
Answers/ Latest Update / Already Graded
Parameters of qsort
Ans: Void * base, size_t nel, size_t width, int (*compar) (const
void*, const void*)) (Pointer to array, element in array, size of
elements, comparator function)
How does the comparator function work?
Ans: Cast the void pointer to the type of pointer in the given
array
Assign the values of the given parameters to the pointers
Subtract a from b
If a < b, return -1
If b < a, return 1
If a == b, return 0
-o flag
Ans: Produces an output file
All rights reserved © 2025/ 2026 |
, Page |2
-Wall flag
Ans: Activates all warnings
-pedantic flag
Ans: Produces more specific warning
-std=c99 flag
Ans: Uses the c99 standard to compile
gcc
Ans: Preprocessor - translate directives "#" into more C code -
Use -E
Linker - connects you object code to standard (or non standard)
libraries default
Compiler - converts C code into object code - Use -c
Linking Libraries
All rights reserved © 2025/ 2026 |
, Page |3
Ans: Use -l(name of library) *no space
Use -L to provide a path to a library isn't in the d efaults
-fPIC flag
Ans: Creates a position independent code; use it when creating
.o file
-shared flag
Ans: Created a shared library
Name your file .so
Allows for one library to be used between multiple applications
export LD_LIBRARY_PATH=.
Ans: Tells the OS the pwd of the shared library at runtime
Make
Ans: Program to make repeated tasks easier
All rights reserved © 2025/ 2026 |