'C' allows the definition of new data type names using the 'typedef' keyword. Using ‘typedef’ we cannot create a new data type, but define a new name for an already existing type. The Chinese translation of
typedef datatype newname;
typedef int bhanu; int a; bhanu a; %d
#include <stdio.h> main (){ typedef int hours; hours h; //int h; clrscr (); printf("Enter hours”); scanf ("%d”, &h); printf("Minutes =%d”, h*60); printf("Seconds = %d”, h*60*60); getch (); }
Enter hours =1 Minutes = 60 Seconds = 360
typedef struct employee{ int eno; char ename[30]; float sal; } emp; main (){ emp e = {10, "ramu”, 5000}; clrscr(); printf("number = %d”, e.eno); printf("name = %d”, e.ename); printf("salary = %d”, e.sal); getch (); }
Number=10 Name=ramu Salary=5000
The above is the detailed content of Use the typedef keyword in C language to interpret structures. For more information, please follow other related articles on the PHP Chinese website!