diff --git a/cpp_1/main.cpp b/cpp_1/main.cpp index 635c7bc..c7a337b 100644 --- a/cpp_1/main.cpp +++ b/cpp_1/main.cpp @@ -1,6 +1,43 @@ #include +#include +#include -int main() { - std::cout << "Hello World!"<< std::endl; +using namespace std; + +void readfile(string file); +void writefile(string file); + +int main() +{ + writefile("./testfile.txt"); + readfile("./testfile.txt"); return 0; +} + +void readfile(string file) +{ + string line; + ifstream myfile; + myfile.open(file); + if (myfile.is_open()) + { + while (getline(myfile, line)) + { + cout << line << '\n'; + } + + myfile.close(); + } +} + +void writefile(string file) +{ + string line; + ofstream myfile; + myfile.open(file,std::ios_base::app); + if (myfile.is_open()) + { + myfile << "hallo\n"; + } + myfile.close(); } \ No newline at end of file diff --git a/cpp_1/program b/cpp_1/program index 8cb0ba9..a8222c4 100755 Binary files a/cpp_1/program and b/cpp_1/program differ diff --git a/cpp_1/testfile.txt b/cpp_1/testfile.txt new file mode 100644 index 0000000..8aab54d --- /dev/null +++ b/cpp_1/testfile.txt @@ -0,0 +1,4 @@ +hallo +hallo +hallo +hallo