1/12
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What does const
mean in C?
It means the variable’s value cannot be changed through that reference.
Why use const
in function parameters?
To guarantee that values won’t be modified, improving safety and clarity.
What does int * const p
mean?
p
is a constant pointer; the address cannot change.
What does const int *p
mean?
p
is a pointer to a constant value; the value cannot change.
What does const int * const p
mean?
p
is a constant pointer to a constant value; neither address nor value can change.
What is the spiral rule in C declaration reading?
Start at the variable name and interpret in this order: arrays → functions → pointers → const.
Interpret char * str[10]
using the spiral rule.
str
is an array of 10 pointers to char
.
What does void func(const struct * const p)
imply?
The struct pointer p
and the struct it points to are both constant.
What is a shallow copy in C structs?
It copies only the pointer, not the data; both structs share the same memory.
What is the purpose of a deep copy constructor?
It allocates new memory and copies data from another struct to a new, uninitialized one.
What does intvector_copy_assign
do?
It copies data into an already-initialized struct, resizing memory safely.
What should you consider before copying a struct?
Whether the struct owns heap memory, to avoid memory issues.
Why is defensive programming important in C?
It prepares your code for future changes and misuse, especially in shared APIs.