summaryrefslogtreecommitdiffstats
path: root/3.03.personenStruktur.cc
diff options
context:
space:
mode:
Diffstat (limited to '3.03.personenStruktur.cc')
-rw-r--r--3.03.personenStruktur.cc68
1 files changed, 68 insertions, 0 deletions
diff --git a/3.03.personenStruktur.cc b/3.03.personenStruktur.cc
new file mode 100644
index 0000000..2bef438
--- /dev/null
+++ b/3.03.personenStruktur.cc
@@ -0,0 +1,68 @@
+/*
+ * =====================================================================================
+ *
+ * Filename: 3.03.personenStruktur.cc
+ *
+ * Description: Personen as globel array
+ *
+ * Version: 1.0
+ * Created: 23.04.2014 21:38:18
+ * 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;
+
+// ##### TYPE DEFINITIONS - LOCAL TO THIS SOURCE FILE #############
+struct mitarbeiter{
+ string identnummer;
+ string nachname;
+ string vorname;
+ string abteilung;
+ unsigned int durchwahl;
+}; // ---------- end of struct mitarbeiter ----------
+
+// ##### VARIABLES - LOCAL TO THIS SOURCE FILE ####################
+const unsigned int MitarbeiterMax = 1000; // max. Anzahl Mitarbeiter
+mitarbeiter ma[MitarbeiterMax]; // Feld mit Mitarbeiter-Beschr.
+// === 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);
+ }
+
+ int satz = 0;
+
+ while ( ifs >> ma[satz].identnummer >> ma[satz].nachname >> ma[satz].vorname >> ma[satz].abteilung >> ma[satz].durchwahl ) {
+ cout << "Person Nr." << satz+1 << "\n"
+ << "\t ID: " << ma[satz].identnummer << "\n"
+ << "\t Nachname: " << ma[satz].nachname << "\n"
+ << "\t Vorname: " << ma[satz].vorname << "\n"
+ << "\t Abteilung: " << ma[satz].abteilung << "\n"
+ << "\t Durchwahl: " << ma[satz].durchwahl << "\n";
+ satz++;
+ }
+
+ ifs.close (); // close ifstream
+ return EXIT_SUCCESS;
+} // ---------- end of function main ----------