A pointer is a variable whose value is a memory address. It's typed, an int * holds the address of an int, and that type determines how many bytes a dereference reads and how pointer arithmetic scales. The two fundamental operations are & (address-of, which produces a pointer to a variable) and * (dereference, which accesses the value living at that address, for both reading and writing). The pointer itself occupies storage like any variable, typically 4 bytes on a 32-bit target, 8 on 64-bit, independent of the size of what it points to.
C Programming · Interview question
What is a pointer, really?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
Pointers & Addresses
A pointer is just a variable that holds an address. Master & and *, NULL, and how passing a pointer lets a function reach back and modify the caller's data.
More Pointers & Addresses questions
Why can't a normal function swap two ints, but a function taking pointers can?What are the ways a pointer can be invalid, and how do you guard against each?How do you read the declaration const int *p versus int *const p?On a microcontroller, how do you read or write a hardware register at a known address?
Browse all 472 interview questions