I want to know how I can implement a function to open a file and read its contents into a linked list, and then print the contents reversed
#include <stdio.h>
typedef struct stack
{
char b[100];
int top;
}stack;
void push(stack *s,char k)
{
if(s->top==99)
printf("\n Stack is full ");
else
s->b[++s->top]=k;
}
char pop(stack *s)
{
char c;
if(s->top==(-1))
printf("\n Stack is empty");
else
c=s->b[s->top--];
return c;
}
void main()
{
char name[100];
stack s;
system("clear") ;
s.top=-1;
printf("\nEnter name :");
gets(name);
int i=0;
while(name[i]!='\0')
{
push(&s,name[i]);
i++;
}
printf("\n Reverse string is :");
while(s.top!=-1)
{
printf("%c",pop(&s));
}
getchar();
}