# Define n 100000
With this definition, using N in a program represents 100000.
Typedef int word4
Give the int A new name word4.
(Transfer)StructDifferences from typedef struct
It can be divided into three parts:
1 first: // Note that C and C ++ are different.
To define a struct type in C, use typedef:
Typedef struct student
{
Int;
} Stu;
So when declaring the variable, you can: Stu stu1; (if there is no typedef, you must use struct student stu1; to declare it)
The Stu here is actually the alias of struct student. Stu = struct student
In addition, student can also be left empty here (so it cannot be struct student stu1; it must be Stu stu1 ;)
Typedef struct
{
Int;
} Stu;
However, in C ++
Struct student
{
Int;
};
As a result, student of the struct type is defined, and student stu2 is directly used when the variable is declared;
========================================================== ===
2. Second:
In C ++, if typedef is used, the following differences may occur:
Struct student
{
Int;
} Stu1 ;// Stu1 is a variable
Typedef struct student2
{
Int;
} Stu2;// Stu2 is a struct type = struct student
You can directly access stu1.a during use.
But stu2 must first stu2 S2;
Then s2.a = 10;
========================================================== =
Typedef and typedef struct and # define