数据结构题编译时提示出错!

来源:百度知道 编辑:UC知道 时间:2024/05/24 20:48:14
warning C4715: “pop”: 不是所有的控件路径都返回值

pop是我的一个函数,我要怎么改才正确!原来的函数是这样的:

link pop(link stack, int *value)
{

link top;
if(stack !=NULL)
{
top=stack;
stack=stack->next;
*value=top->data;
free(top);
return stack;
}
else
*value=-1;
}

你else语句没有return 语句啊。当然会有警告了,你可以加个return NULL;什么的,应该就可以了

大哥,你operator是int型,怎么可能出现+,-,*,/这四种情况。是char型变量才可能啊!还有,但你operator要是没有出现以上四种情况中的任何一种类,也就是没有匹配的,那返回什么啊。
应该是这样:
int two_result(char operator,int operand1,int operand2)
{int a;
switch(operator)
{
case '+':a=(operand2+operand1);return a;
case '-':a=(operand2-operand1);return a;
case '*':a=(operand2*operand1);return a;
case '/':a(operand2/operand1);return a;
}
return NULL;
}