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 ?
- 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 133 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.