This program is supposed to get user data in the form of a string and put it into a linked list. Right now I am able to get the data into the linked list but not sure why its not printing them out.
#include<stdio.h>
#include<stdlib.h>
// define the node of the stack
typedef struct node{
    char name[100];
    struct node *next;
}Node, *NodePtr;
// define the stack based on the linked list of nodes
typedef struct{
    NodePtr top;
}StackType,*Stack;
// implement all the stack operations
Stack initStack(){
    // allocate memory
    Stack sp=(Stack)malloc(sizeof(StackType));
    // set the top pointer to NULL
    sp->top=NULL;
    return sp;
}
int empty(Stack s){
    return (s->top==NULL);
}
void push(Stack s, char *n){
    NodePtr np= (NodePtr) malloc(sizeof(Node));
    strcpy(np->name,n);
    np->next=s->top;
    s->top=np;
}
I think there is a problem in the pop function somewhere but cant seem to figure it out
//  pop the top element from the stack
char* pop(Stack s){
    if(empty(s)){
        printf("\n Error: Stack is empty");
        return("err");
    }
    char hold[100];
    strcpy(hold,s->top->name);
    NodePtr temp=s->top;
    s->top=s->top->next;
    free(temp);
    return hold;
}
int main(){
    char n[100];
    // create the stack
    Stack s=initStack();
    printf("Enter a list of names\n");
    scanf("%s",&n);
    while(strcmp(n,"end")!=0){
        push(s,n);
        scanf("%s",&n);
    }
    // print the stack
    while(!empty(s))
        printf("%s \n ", pop(s));
}
 
     
    