005
17.06.2007, 15:12 Uhr
xXx
Devil
|
hmm erstmal kurz deine Funktion etwas verbessern:
C++: |
bool write_person(const std::string& filename, const std::string& prename, const std::string& name) { std::ofstream file_stream(filename.c_str()); if (!file_stream) return false; file_stream << prename << std::endl; file_stream << name << std::endl; return file_stream.good(); }
|
?
C++: |
#include <fstream> #include <iostream> #include <string>
bool write_person(const std::string&, const std::string&, const std::string&);
int main() { std::cout << "(1) Konto erstellen" << std::endl; std::cout << "Eingabe: "; unsigned short input = 0; std::cin >> input; switch (input) { case 1: { std::cout << "Vorname: "; std::string prename; std::cin >> prename; std::cout << "Nachname: "; std::string name; std::getline(std::cin, name); std::string file_name("data\\users\\"); file_name += prename; file_name += "_"; file_name += name; file_name += ".txt"; write_person(filename, prename, name); } break; case 2: std::cout << "Test" << std::endl; break; } }
bool write_person(const std::string& filename, const std::string& prename, const std::string& name) { std::ofstream file_stream(filename.c_str()); if (!file_stream) return false; file_stream << prename << std::endl; file_stream << name << std::endl; return file_stream.good(); }
|
|