我在将结构传递给以结构指针作为参数的函数时遇到问题,并不断收到错误“错误:一元'*'的无效类型参数(具有'StackNode')”
这是我的代码的必要部分(不是全部):
#include <stdio.h>
#include <stdlib.h>
struct stackNode{
char data;
struct stackNode *nextPtr;
};
typedef struct stackNode StackNode;
typedef StackNode *StackNodePtr;
void convertToPostfix(char infix[], char postfix[]);
int isOperator(char c);
int precedence(char operator1, char operator2);
void push(StackNodePtr *topPtr, char value);
char pop(StackNodePtr *topPtr);
char stackTop(StackNodePtr topPtr);
int isEmpty(StackNodePtr topPtr);
void printStack(StackNodePtr topPtr);
int main(){
convertToPostfix(NULL, NULL);
return 0;
}
void convertToPostfix(char infix[], char postfix[]){
StackNode stack = {'(', NULL};
push(*stack, 'a');
printStack(&stack);
}
void push(StackNodePtr* topPtr, char value){
topPtr->nextPtr = NULL; //just temporary, not needed
topPtr->data = value; //just temporary, not needed
}
任何帮助将不胜感激,谢谢