Yurttas/PL/OOL/Cplusplus/F/07/02/02/00/get vector lines.cpp

 1/*
 2   Copyright(C) 2002
 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, 2002.
11   authorĀ : Salih Yurttas.
12
13   get_vector_lines.cpp
14*/
15
16
17#include "common.h"
18#include "io.h"
19
20using namespace std;
21
22vector<string> get_vector_lines() {
23  vector<string> lines;
24
25  string filename;
26
27  cout << endl;
28  cout << "--> input filenameĀ : ";
29  cin >> filename;
30
31  ifstream f_in(filename.c_str());
32
33  if(!f_in) {
34    cerr << "File named as " << filename << " is not opened for input." << endl;
35    exit(1);
36  }
37  else {
38    string t;
39
40    while(getline(f_in,
41                  t,
42                  '\n'))
43      lines.push_back(t);
44  }
45
46  f_in.close();
47
48  return lines;
49}