#include
#include
#include
using namespace std;
//用途一:为普通变量定义易于记忆的类型名
typedef int Integer;
//用途二:掩饰复合数据类型,如数组和指针
typedef char Line[20];
typedef char* ptr;
//用途三:给链表定义别名
typedef struct Student
{
char StuNo[20];
char StuName[30];
}Stu;
int main()
{
//用途一举例
Integer num = 9;
cout<<"num = "<
//用途二举例(数组)
Line str1,str2;
strcpy(str1, "hello");
strcpy(str2, "world");
cout<<"str1 + str2 = "<
//用途二举例(指针)
ptr p = str1;
for(int i = 0; p[i] != '\0'; p++)
{
}
//用途三举例
Stu student = {"1001001", "盟主仁兄"};
cout<<"学号:"<"<
return 0;
}
运行结果如下:
阅读(1247) | 评论(1) | 转发(0) |