Yurttas/PL/OOL/Cplusplus/F/05/04/03/01/get vector item.cpp
Jump to navigation
Jump to search
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 : January 1, 2002.
11 author : Salih Yurttas.
12
13 get_vector_item.cpp
14*/
15
16
17#include "get_put_vector_item.h"
18
19using namespace std;
20
21template<class T>
22void get_vector_item(vector<T>& list) {
23 string filename;
24
25 cout << "--> input filename : ";
26 cin >> filename;
27 cout << endl;
28
29 ifstream f_in(filename.c_str());
30
31 if(!f_in) {
32 cerr << "File named as " << filename << " is not opened for input." << endl;
33 exit(1);
34 }
35 else {
36 T v;
37 while(f_in>>v)
38 list.push_back(v);
39 }
40
41 f_in.close();
42}