1/43
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
= assigns; == compares
What is the difference between = and == in C?
Declaration tells the compiler the type; definition allocates storage
What is a declaration vs definition?
Value cannot be modified through that identifier
What does const mean?
Variable keeps its value between calls
What does static mean inside a function?
Visible only in that file (internal linkage)
What does static mean at global scope?
A variable that stores a memory address
What is a pointer?
& gets address; * dereferences.
What do & and * mean?
Adding 1 moves by the size of the pointed-to type.
Pointer arithmetic rule?
Indicates "no valid address."
Null pointer purpose?
char * is a pointer; char[] is a fixed array. Arrays cannot be reassigned.
Difference between char *s and char s[]?
void* pointing to allocated memory; NULL on failure.
What does malloc return?
Portable across systems.
Why use sizeof(type) instead of a number?
Memory leak.
What happens if you forget free?
Pointer to freed memory.
What is a dangling pointer?
No bounds checking — can overflow buffer
Why is strcpy dangerous?
Measures visible characters only.
Why strlen(s) doesn't count '\0'?
Compiler inserts bytes to align fields for performance.
What is padding?
ptr->field
How to access struct members through a pointer?
fopen = buffered stdio; open = low-level system call.
Difference between fopen and open?
Number of bytes read or 0 (EOF) or -1 (error).
What does read() return?
No formatting overhead.
Why is system call I/O faster for large files?
Moves file offset (random access).
What does lseek do?
0 to child, child's PID to parent, -1 on error.
What does fork() return?
Two — parent and child.
After fork(), how many processes run?
Child receives a copy of the parent's address space (copy-on-write).
Why is code duplicated after fork()?
Parent waits for specific child to finish.
What does waitpid(pid, &status, 0) do?
WEXITSTATUS(status).
How to get child’s exit code?
Replaces current process image with a new program
What does exec() do?
Nothing returns — the original code is gone.
What happens after successful exec()?
Child starts a new program.
Why call exec() after fork()?
Asynchronous notification to a process
What is a signal?
Terminate program
Default SIGINT behavior?
More reliable; portable; supports flags (like SA_RESTART).
Why use sigaction instead of signal?
Function automatically called when signal arrives
What is a signal handler?
Must only use async-safe functions (e.g., write, not printf).
Restrictions in signal handlers?
text, data, stack, heap
What are the 4 main memory sections?
Stack
What grows downward?
Heap
What grows upward?
Data (initialized) or BSS (uninitialized)
Where are globals stored?