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