Pointer error in stack project’s header file with C

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:

#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

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?

Read more here: https://stackoverflow.com/questions/66997059/pointer-error-in-stack-projects-header-file-with-c

Content Attribution

This content was originally published by Muhammad Riziq at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: