Pointers in C Language: 20 flashcards

All 20 flashcards from this kit, free and with no sign-up.

1. What is a pointer in C?

Show the answer

A variable that holds a memory address.

2. Which operator returns the address of a variable?

Show the answer

The `&` (address-of) operator.

3. What does the `*` operator do when applied to a pointer?

Show the answer

Dereferences it — accesses the value stored at the address.

4. How do you declare a pointer to an int?

Show the answer

`int *p;`

5. What does an array name decay to in most expressions?

Show the answer

A pointer to its first element.

6. How far does `p + 1` advance for an `int *p` when `int` is 4 bytes?

Show the answer

4 bytes — pointer arithmetic is type-sized.

7. Why pass a pointer to a function?

Show the answer

So the function can modify the caller's variable or avoid copying large data.

8. Why does `scanf` need `&x`?

Show the answer

It needs the address to store the input into `x`.

9. What does `malloc` return?

Show the answer

A pointer to heap memory (or `NULL` on failure).

10. What must you do with memory from `malloc`?

Show the answer

`free` it to avoid memory leaks.

11. What is a null pointer?

Show the answer

A pointer that points to nothing (`NULL`); check before dereferencing.

12. What happens when you dereference an uninitialized or invalid pointer?

Show the answer

Undefined behavior — often a crash.

13. What does `int **pp;` declare?

Show the answer

A pointer to a pointer to an int.

14. What is a dangling pointer?

Show the answer

A pointer that still holds the address of memory already freed.

15. Does `int *a, b;` declare two pointers?

Show the answer

No — `a` is a pointer, `b` is an int. Use `int *a, *b;`.

16. What does `sizeof(arr)` give versus `sizeof(ptr)`?

Show the answer

`sizeof(arr)` gives total array size; `sizeof(ptr)` gives pointer size.

17. What is the difference between `*p = &x;` and `p = &x;`?

Show the answer

`*p = &x;` is a type error (stores address into int); `p = &x;` is correct.

18. What do function pointers enable?

Show the answer

Callbacks and dynamic dispatch.

19. Why are pointers essential for linked lists and trees?

Show the answer

They link elements by address, enabling dynamic structures.

20. Is pointer arithmetic valid outside the same array?

Show the answer

No — only within the same array or one past the end.

Make your own

Your notes can be a kit like these

Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free, in 42 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Exam prep

Get Veda free See what students get

Free to start · No ads · Works in 42 languages