我正在尝试编写一个实现Pop和Push功能的程序.问题是,我试图将指向整数Top的指针传递给函数,这样整数不断变化,但是当我尝试编译时,我总是得到这个行:
**error: called object is not a function or function pointer (*t)–
#include<stdio.h> #include<stdlib.h> #define MAX 10 int push(int stac[],int *v,int *t) { if((*t) == MAX-1) { return(0); } else { (*t)++; stac[*t] = *v; return *v; } } int pop(int stac[],int *t) { int poped; if((*t) == -1) { return(0); } else { poped = stac[*t] (*t)--; return poped; } } int main() { int stack[MAX]; int value; int choice; int decision; int top; top = -1; do{ printf("Enter 1 to push the value\n"); printf("Enter 2 to pop the value\n"); printf("Enter 3 to exit\n"); scanf("%d",&choice); if(choice == 1) { printf("Enter the value to be pushed\n"); scanf("%d",&value); decision = push(stack,&value,&top); if(decision == 0) { printf("Sorry,but the stack is full\n"); } else { printf("The value which is pushed is: %d\n",decision); } } else if(choice == 2) { decision = pop(stack,&top); if(decision == 0) { printf("The stack is empty\n"); } else { printf("The value which is poped is: %d\n",decision); } } }while(choice != 3); printf("Top is %d\n",top); }
解决方法
原文地址:https://www.jb51.cc/c/114206.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。