i'm currently doing an assignment on making stack in the C language using a header, source, and main file. I'm trying out this code my professor made but there's an error in the header file i couldn't solve. Code: stack.h
#ifndef stack_H
#define stack_H
#include <stdio.h>
#include <stdbool.h>
#define Nil 0
#define MaxEl 10
typedef int infotype;
typedef int address;
typedef struct{
infotype T[MaxEl+1];
address TOP;
} Stack;
#define Top(S) (S).TOP //the error is this line
#define InfoTop(S) (S).T[(S).TOP]
/*Body Prototype*/
/*** Constructor***/
void CreateEmpty(Stack *S);
bool isEmpty(Stack S);
#endif // stack_H
stack.c
#ifndef stack.c
#define stack.c
#include "stack.h"
#include <stdio.h>
void CreateEmpty(Stack *S){
Top(S)=Nil;
}
bool isEmpty(Stack S){
return Top(S)==Nil;
}
#endif
main.c
#include <stdio.h>
#include <stdlib.h>
#include "stack.h"
int main()
{
Stack S;
CreateEmpty(&S);
}
the error says: 'S' is a pointer; did you mean to use '->'?
i'm pretty sure i copied my professor's code almost completely yet the error still persists. Any suggestions on how to fix this problem?