summaryrefslogtreecommitdiffstats
path: root/3.02.rohdatenLesen.cc
blob: bab932a5ecea513cfc12583832a0755cf8b55191 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// =====================================================================================
//
//       Filename:  3.02.rohdatenLesen.cc
//
//    Description:  Reads data from a file
//
//        Version:  1.0
//        Created:  23.04.2014 12:46:15
//       Revision:  none
//       Compiler:  gcc
//
//         Author:  Stefan Suhren (SSuhren), suhren.stefan@fh-swf.de
//   Organization:  FH SĂĽdwestfalen, Iserlohn
//
// =====================================================================================

#include	<cstdlib>
#include	<iostream>
#include	<iomanip>
#include	<fstream>
#include	<string>

using namespace std;
// ===  FUNCTION  ======================================================================
//         Name:  main
//  Description:  Reading and printing the personen.dat file
// =====================================================================================
int main ( int argc, char *argv[] ){

	string    ifs_file_name = "personen.dat";     // input  file name 
	ifstream  ifs;                                // create ifstream object 

	ifs.open ( ifs_file_name.c_str() );           // open ifstream 
	if (!ifs) {
		cerr << "\nERROR : failed to open input file " << ifs_file_name << endl;
		exit (EXIT_FAILURE);
	}
	
	string identnummer; // Idenditätsnummer
	string nachname; // Nachname
	string vorname; // Vorname
	string abteilung; // Abteilungsbezeichnung
	unsigned int durchwahl; // Telefondurchwahl

	int satz = 0;

	while ( ifs >> identnummer >> nachname >> vorname >> abteilung >> durchwahl ) {
		satz++;
		cout << "Person Nr." << satz << "\n"
			 << "\t ID:        " << identnummer << "\n"
			 << "\t Nachname:  " << nachname    << "\n"
			 << "\t Vorname:   " << vorname     << "\n"
			 << "\t Abteilung: " << abteilung   << "\n"
			 << "\t Durchwahl: " << durchwahl   << "\n";
	}

	ifs.close ();                                 // close ifstream 
	return EXIT_SUCCESS;
}				// ----------  end of function main  ----------