数据结构学习笔记1
(1) typedef 起别名 (2) struct C++中定义一个结构体类型
(3) typedef struct C中定义一个结构体类型:
typedef struct Student // Student可省略
{
int a;
}Stu; //这里Stu相当于struct Student
(4) Status
1.这里的Status是一个结构或变量类型。STATUS是返回的状态,程序中的error,ok就是和它对应的!
2.typedef int Status; /*类型名定义用status代替int*/ 这样你应该理解了吧,status push(linkstack top,elemtype e) 的意思就是:int push(linkstack top,elemtype e),Status只是int的替身。 原文:https://blog.csdn.net/sugesi/article/details/53823479
typedef用法总结:
在C和C++编程语言中,typedef
是一个关键字。它用来对一个数据类型取一个别名(更容易读)。它通常用于简化声明复杂的类型组成的结构 ,但它也常常在各种长度的整数数据类型中看到,例如size_t
和time_t
。
创建 Length
作为 int
的别名 : typedef int Length;
创建 PFI
作为一个指向 "一个拥有两个 char *
当作参数并回传 int
的函数" 的指针的别名 typedef int (*PFI)(char *, char *);
数组:
typedef char arrType[6]; // type name: arrType
// new type: char[6]
arrType arr={1,2,3,4,5,6}; // same as: char arr[6]={1,2,3,4,5,6}
arrType *pArr; // same as: char (*pArr)[6];
在这里,arrType是char[6]的别称。而arrType *pArr;则表示pArr是一个指向存储char[6]类型存储器的指针。
指针:
typedef int *intptr; // type name: intptr
// new type: int*
来自:*
struct与typedef struct 区别:https://www.cnblogs.com/qyaizs/articles/2039101.html