我在將結構傳遞給一個將結構指針作爲參數的函數時遇到問題,並且不斷收到錯誤「錯誤:一元'的無效類型參數*'(' StackNode')」將結構指針傳遞給函數C
這裏是我的代碼(必要的部分不是全部的話):
#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
}
任何幫助將不勝感激,謝謝
謝謝您的回答,這個工程只要我從我的push方法去除多餘的*,但是是 – nain33