I have a program made of 3 files.
main.c contains the external variables for the stack and contains the code to parse input and pass the input to the functions in stack.c
stack.c //contains the functions to execute the operations on the stack push/pull etc
- stack.h //contains the function prototypes
The program currently uses a global integer array as a stack.
Im now trying to convert the program to use a linked list for the stack instead of the integer array.
My issue is I don’t know where I should declare the struct and where I should declare the struct members. Should i put them in the main.c outside the main function, in the stack.h header file ?
my struct declaration
struct node {
int value;
struct node *next;
};
struct node *first = NULL;
struct node *new_node = NULL;
new_node = malloc(sizeof(struct node));
new_node = malloc(sizeof(struct node));must be inside a function (eg main()), since it generates "code", not "data". - wildplasser