Arrow Operator with Pointers in C/C++: 22 flashcards

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

1. What is a structure in C?

Show the answer

A user-defined data type that groups variables of different data types under a single name.

2. What is a member (or field) of a structure?

Show the answer

Each individual variable declared inside a structure definition.

3. Which keyword introduces a structure definition?

Show the answer

The `struct` keyword.

4. What is a structure tag?

Show the answer

The name given to the structure blueprint, e.g. `Student` in `struct Student`.

5. Does a structure definition allocate memory?

Show the answer

No. The definition is only a blueprint; memory is allocated when a variable of that structure type is declared.

6. What punctuation is required after the closing brace of a structure definition?

Show the answer

A semicolon (`;`).

7. How do you declare a structure variable for `struct Student`?

Show the answer

`struct Student s1;`

8. Which operator accesses members of a structure variable?

Show the answer

The dot operator (`.`), e.g. `s1.rollNo`.

9. How do you declare a pointer to a structure?

Show the answer

`struct Student *ptr = &s1;` — the pointer stores the address of the structure.

10. Which operator accesses members through a pointer to a structure?

Show the answer

The arrow operator (`->`), e.g. `ptr->rollNo`.

11. What is `ptr->member` equivalent to?

Show the answer

`(*ptr).member` — dereference the pointer, then access the member.

12. Why are parentheses essential in `(*ptr).member`?

Show the answer

Because `.` binds tighter than `*`; without parentheses `*ptr.member` would be parsed as `*(ptr.member)`, which is wrong.

13. What is the difference between passing a structure by value and by pointer?

Show the answer

By value copies all members; by pointer copies only an address (typically a few bytes).

14. Can a function receiving a structure pointer modify the caller's structure?

Show the answer

Yes — because the pointer refers to the original memory, changes are visible outside the function.

15. State the rule for choosing between dot and arrow.

Show the answer

Structure variable → dot (`.`); pointer to structure → arrow (`->`).

16. What happens if you write `ptr.member` when `ptr` is a pointer?

Show the answer

A compile error — the dot operator cannot be applied to a pointer to a structure.

17. What happens if you write `var->member` when `var` is a structure variable?

Show the answer

A compile error — the arrow operator requires a pointer to a structure.

18. Why was the arrow operator introduced?

Show the answer

To avoid the clumsy `(*ptr).member` syntax when accessing members through a pointer.

19. Name three real-world uses of structures with pointers.

Show the answer

Linked lists, file records, and network packet headers.

20. In a linked list node, what does the structure typically contain?

Show the answer

Data plus a pointer to the next node.

21. Write the C statement that updates `marks` of `s1` through pointer `ptr`.

Show the answer

`ptr->marks = 92.0;`

22. If `ptr = &s1`, does `ptr->marks = 92.0` change `s1.marks`?

Show the answer

Yes — `ptr` points at `s1`, so they share the same memory.

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