80年代香港男演员大全:定义函数时的status 的用处是什么

来源:百度文库 编辑:神马品牌网 时间:2024/05/01 10:11:11
举个例子:
status push(linkstack top,elemtype e)
{
p=(linkstack)malloc(sizeof(snode));//建新结点
if(!p) return OVERFLOW;
p->data=e;
p->next=top->next;
top->next=p;//在表的第一元素之前插入新结点
return OK;
}
这个status 是用来做什么的呢。谢谢

完整的话,你还应该告诉我定义这个函数之前,代码里有“类似”这样的一个语句:
typedef int Status; /*类型名定义用status代替int*/

这样你应该理解了吧,status push(linkstack top,elemtype e) 的意思就是:int push(linkstack top,elemtype e),Status只是int的替身。

typedef语句的功能是为现有类型创建一个新的名字。

如果你的代码里有:typedef char Status; 那么这里status push的意思应该是 char push。

如有问题再和我联系。

完整的话,你还应该告诉我定义这个函数之前,代码里有“类似”这样的一个语句:
typedef int Status; /*类型名定义用status代替int*/

这样你应该理解了吧,status push(linkstack top,elemtype e) 的意思就是:int push(linkstack top,elemtype e),Status只是int的替身。

typedef语句的功能是为现有类型创建一个新的名字。

如果你的代码里有:typedef char Status; 那么这里status push的意思应该是 char push。

Status是函数的类型,其值是函数结果的状态代码。。