C programming, error: called object is not a function or function pointer -
C programming, error: called object is not a function or function pointer -
i trying write programme implements pop , force functions. problem is, trying pass pointer points integer top function, integer keeps changing, when seek compile line:
**error: called object not 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; homecoming *v; } } int pop(int stac[], int *t) { int poped; if((*t) == -1) { return(0); } else { poped = stac[*t] (*t)--; homecoming poped; } } int main() { int stack[max]; int value; int choice; int decision; int top; top = -1; do{ printf("enter 1 force value\n"); printf("enter 2 pop value\n"); printf("enter 3 exit\n"); scanf("%d", &choice); if(choice == 1) { printf("enter value pushed\n"); scanf("%d", &value); decision = push(stack, &value, &top); if(decision == 0) { printf("sorry, stack full\n"); } else { printf("the value pushed is: %d\n", decision); } } else if(choice == 2) { decision = pop(stack, &top); if(decision == 0) { printf("the stack empty\n"); } else { printf("the value poped is: %d\n", decision); } } }while(choice != 3); printf("top %d\n", top); }
you missed 1 semicolon before line error:
poped = stac[*t] <----- here (*t)--;
the reason unusual error compiler saw sth that:
poped = stac[*t](*t)--;
which interpret phone call function pointer coming table, makes no sense, because stac array of ints, not array of function pointers.
c compiler-errors function-pointers semicolon
Comments
Post a Comment