Created
December 8, 2015 09:57
-
-
Save leolabs/f39187d3b5ff687bbdbc to your computer and use it in GitHub Desktop.
Praktikumsaufgabe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include "functions.h" | |
using namespace std; | |
struct person { | |
string firstName = ""; | |
string lastName = ""; | |
string birthday = ""; | |
}; | |
person generatePersonFromString(string input) { | |
person tmpPerson; | |
string lastName = ""; | |
string part2 = ""; | |
spalte_ab_erstem(input, ',', lastName, part2); | |
string firstName = ""; | |
string birthday = ""; | |
spalte_ab_erstem(part2, ',', firstName, birthday); | |
lastName = trimme(lastName); | |
firstName = trimme(firstName); | |
birthday = trimme(birthday); | |
tmpPerson.lastName = lastName; | |
tmpPerson.firstName = firstName; | |
tmpPerson.birthday = birthday; | |
return tmpPerson; | |
} | |
int main() { | |
person persons[100]; | |
// Personendaten einlesen | |
ifstream personsFile; | |
string person = ""; | |
personsFile.open("personendaten.txt"); | |
if(!personsFile.is_open()) { | |
cerr << "Personendaten konnten nicht geöffnet werden"; | |
return 1; | |
} | |
// Personendatenbank aufbauen | |
int i = 0; | |
while(getline(personsFile,person)) { | |
persons[i++] = generatePersonFromString(person); | |
cout << person << '\n'; | |
} | |
personsFile.close(); | |
// L | |
string listShort = ""; | |
string listLong = ""; | |
for(int j = 0; j < i-1; j++) { | |
listShort += ("<b>" + persons[j].lastName + "</b>, " + persons[j].firstName + "<br />\r"); | |
listLong += ("<b>" + persons[j].lastName + " " + persons[j].firstName + "</b>, " + persons[j].birthday + "<br />\r"); | |
} | |
// Website-Template einlesen | |
ifstream templateFile; | |
string templates = ""; | |
templateFile.open("webseite.html.tmpl", ios::in); | |
string line = ""; | |
while(getline(templateFile, line)) templates += line; | |
templates = ersetze(templates, '%', listShort); | |
templates = ersetze(templates, '$', listLong); | |
fstream output("webseite.html", ios::out); | |
output << templates; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment