What is typedef in C?
#include <stdio.h>
typedef struct {
int roll;
char name[20];
} Student;
int main(void) {
Student s = {1, "Robin"};
printf("%d %s\n", s.roll, s.name);
return 0;
}
Output:
Output of the above program is
1 Robin
We wrote Student instead of struct Student. typedef does not create a new type, only a new name. See C typedef.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |