Code:
#include <string.h>
#include <stdlib.h>
#define MAXLENGTH 30
typedef struct node {
char word[MAXLENGTH];
}DATA;
typedef struct stack {
DATA data[MAXLENGTH];
int top;
}Stack;
void write(FILE *filee,Stack* st) {
while(!feof(filee)) {
st->top++;
fgets(st->data[st->top].harf,MAXLENGTH,filee);
//printf("%s",st->data[st->top].word);
}
}
void read(Stack* st) {
FILE *filee;
filee=fopen("example.txt","r");
write(filee,st);
}
int main() {
int i;
Stack st;
st.top=-1;
read(&st);
for(i=0;i<=st.top;i++) {
printf("%s\n",st.data.word);
}
}