Hi,
typedef allows you to give a new name to user-defined data type.
typedef is used to improve code readability.
#include <stdio.h>
typedef struct Sample {
char name[50];
int id;
} typedef_Sample;
int main()
{
typedef_Sample sp;
strcpy(sp.name, "hello");
sp.id = 10;
printf("%s,%d", sp.name, sp.id);
return 0;
}
Best regards,
Minxin Yu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.