daily pastebin goal
56%
SHARE
TWEET

Untitled

a guest Oct 12th, 2017 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void List::read(FILE *f){
  2.     int v;
  3.     char buf[LEN];
  4.  
  5.     if (fscanf(f, "%s%d", buf, &v) != 2){
  6.         if (!feof(f)){
  7.             throw "read error";
  8.             return;
  9.         }
  10.         throw "no elements in file";
  11.         return;
  12.     }
  13.     curr = new Node(buf, v);
  14.     head = curr;
  15.     for(Node *prv = curr;;curr = curr->next, curr->prev = prv, prv = curr){
  16.         if (fscanf(f, "%s%d", buf, &v) != 2){
  17.             if (!feof(f)){
  18.                 throw "read error";
  19.                 return;
  20.             }
  21.             return;
  22.         }
  23.         Node *nxt = new Node(buf, v);
  24.         curr->next = nxt;
  25.     }
  26.     return;
  27. }
RAW Paste Data
Top