Computer Networking
Databases
Languages
Production Software
Real_Time_Systems
Security

C Typedef

  • Gives a datatype a "nickname"

  • The following:

char user1[25] = "hi";
char user2[25] = "yo";
char user3[25] = "wsg";
  • Can be changed to:
typedef char user[25];
user user1 = "hi";
user user2 = "yo";
user user3 = "wsg";
  • Can also be used with a struct
typedef struct{
char name[25];
} bacon;

bacon hello = {"hello"};
strcpy(hello.name, "Good evenin!");