What is the purpose of typedef in C when used with structures ?
2024
What is the purpose of typedef in C when used with structures ?
Answer: A. To define a new data type based on an existing one — typedef creates an alias for a structure type, allowing you to define variables without the struct keyword. For example, typedef struct {int x;} Point; lets…
- A.
To define a new data type based on an existing one
- B.
To declare a structure
- C.
To specify the size of a structure
- D.
To initialize a structure
Attempted by 356 students.
Show answer & explanation
Correct answer: A
typedef creates an alias for a structure type, allowing you to define variables without the struct keyword. For example, typedef struct {int x;} Point; lets you write Point p instead of struct Point p.
Loading lesson…