Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct STUDENT {
- int id;
- char name[30];
- struct STUDENT* next;
- struct STUDENT* prev;
- } S;
- int main() {
- char name[30];
- int num, i;
- FILE* input = fopen("blabla.txt","r");
- S* first = (S*)malloc(sizeof(S));
- first->prev=NULL;
- S* current = first;
- S* temp;
- while(fscanf(input,"%d %s",¤t->id,current->name)==2)
- {
- current->next = (S*)malloc(sizeof(S));
- temp = current;
- current = current->next;
- current->prev = temp;
- }
- current->id = -1; //last one
- for(current=first; current->id!=-1; current=current->next)
- printf("%d %s\n",current->id,current->name);
- // printf("%d %s\n",first->id,first->name);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement