Facebook
From LiLo, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 123
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <list>
  5. #include <iterator>
  6. using namespace std;
  7.  
  8. int main(void) {
  9.     int f;
  10.     fstream newfile;
  11.     newfile.open("testInput.txt", ios::in);
  12.     if (newfile.is_open()) {
  13.         list<int*> l1;
  14.         int *p;
  15.         string line;
  16.         while (getline(newfile, line)) {
  17.             string line;
  18.             getline(cin, line);
  19.             f = line.find("|");
  20.             p = new int[2];
  21.             //cout << stoi(line.substr(0, f - 1));
  22.             p[0] = stoi(line.substr(0, f));
  23.             p[1] = stoi(line.substr(f + 1, string::npos));
  24.             l1.push_back(p);
  25.            
  26.         }
  27.         newfile.close();
  28.         /*while (!l1.empty()) {
  29.             p = l1.front();
  30.             std::cout << "List contains: " << p[0] << " " << p[1] << std::endl;
  31.             l1.pop_front();
  32.             delete[] p;
  33.         }*/
  34.     }
  35.  
  36.    
  37. }

Replies to Untitled rss

Title Name Language When
Re: Untitled LiLo text 3 Years ago.