Yurttas/PL/OOL/Cplusplus/F/07/06/00/04/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
19template<class T>
20void get_vector_item(vector<T>& list) {
21 string filename;
22
23 cout << endl;
24 cout << "--> input filename : ";
25 cin >> filename;
26
27 ifstream f_in(filename.c_str());
28
29 if(!f_in) {
30 cerr << "File named as " << filename << " is not opened for input." << endl;
31 exit(1);
32 }
33 else {
34 T v;
35 while(f_in>>v)
36 list.push_back(v);
37 }
38
39 f_in.close();
40}