Yurttas/PL/OOL/CS/F/02/05/10/00/03/get data.cpp

From ZCubes Wiki
Jump to navigation Jump to search
 1/*
 2   Copyright(C) 2003
 3   All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4
 5   Permission to use, copy, modify, and distribute this
 6   software and its documentation for EDUCATIONAL purposes
 7   and without fee is hereby granted provided that this
 8   copyright notice appears in all copies.
 9
10   date   : September 1, 2003.
11   author : Salih Yurttas.
12
13   get_data.cpp
14*/
15
16
17#include "common.h"
18
19#include "io.h"
20
21string get_filename(string);
22
23vector<string> get_data() {
24  vector<string> d;
25
26  string filename = get_filename("input");
27
28  ifstream f_in(filename.c_str());
29
30  if(!f_in) {
31    cerr << "File named as " << filename << " is not opened for input." << endl;
32    exit(1);
33  }
34  else {
35    string s;
36
37    while(getline(f_in,
38                  s,
39                  '\n'))
40      d.push_back(s);
41  }
42
43  f_in.close();
44
45  return d;
46}