From b2f7e26d27f2bc58a20cbba98d81b9243c96467d Mon Sep 17 00:00:00 2001 From: Stefan Suhren Date: Thu, 8 May 2014 12:11:20 +0200 Subject: Assignment No. 3 These are the linked listes and personen structs. --- 3.02.rohdatenLesen.cc | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 3.02.rohdatenLesen.cc (limited to '3.02.rohdatenLesen.cc') diff --git a/3.02.rohdatenLesen.cc b/3.02.rohdatenLesen.cc new file mode 100644 index 0000000..bab932a --- /dev/null +++ b/3.02.rohdatenLesen.cc @@ -0,0 +1,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 +#include +#include +#include +#include + +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 ---------- -- cgit v1.2.3-70-g09d2