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