c - ->token 之前的错误

标签 c

<分区>

我正在实现算术计算器,但出现错误:

错误:')' 标记前应为主表达式 错误:'->' 标记之前的预期主表达式

我发布了包含错误的行。

    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
    /*creating stack*/        
    typedef struct stack
    {
    int top;
    char *array;
    int max_size;
    }S;
    /*pushing character to it*/ 
    void push(S *st ,char ch)
    {
    if(st->top==st->max_size)
    {printf("already full..delete some items :)");return ;}
        printf("st->top=%d ",st->top);
        strcpy(&st->array[st->top],&ch);
        st->top++;
        printf("push=%s ",st->array[st->top-1]);
    }
    /*deleting character*/ 
    void pop(S *st)
    {
    if(st->top==0)
    {printf("it's empty..push some items :)");return ;}

        st->top--;
    }
    void fun(S *stack,S *post,char a)
    {
        while(strcmp((&stack->array[stack->top]),&a)!=0)
            {
                pop(stack);
                push(post,stack->array[stack->top+1]);

            }
            pop(stack);
    }
    int main()
    {
    int i,j;
    char str[10000];
    /*initialize 3 stacks*/
    S *st =init(10000);
    S *post=init(10000);
    S *ans=init(10000);
    / *actually code is very big so i am
    giving only lines in which there is error*/
    //some code...
    fun(stack,post,a);
    //some code...
             while(precedence(str[i])>precedence(stack->array[stack->top]))
    //some code...
    push(post,stack->array[stack->top]);
    pop(stack);
    //more code......
    }

最佳答案

您有一个结构和一个同名stack 的变量。这非常糟糕,会让您和编译器感到困惑。对结构/类名称使用大写字母。

关于c - ->token 之前的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14401151/

相关文章:

c - c中字符串的最小值和最大值

C fork ,返回父进程的 PID 后杀死父进程

将 MIPS32 转换为 C : adding an array's base address to arbitrary value and its meaning

c - unsetenv() 实现,是否需要释放内存?

C: 如何在编译内核模块时手动添加依赖

c - 在 C 中共享公共(public)数据以进行科学计算

使用 O_DIRECT 一致写入许多 block

c - 寻求可以在Delphi和C中处理整个文件加密/解密的单个文件加密实现

c - 显示链接列表时出现运行时错误的原因可能是什么

C - 使 msgrcv 与信号共存