add param to writefunction

This commit is contained in:
lucaspalomodevelop 2022-11-02 18:59:12 +01:00
parent 7608773cab
commit 1de13ffb1d
3 changed files with 4 additions and 8 deletions

View File

@ -5,11 +5,11 @@
using namespace std; using namespace std;
void readfile(string file); void readfile(string file);
void writefile(string file); void writefile(string file, string text);
int main() int main()
{ {
writefile("./testfile.txt"); writefile("./testfile.txt","Hallo Welt!");
readfile("./testfile.txt"); readfile("./testfile.txt");
return 0; return 0;
} }
@ -30,14 +30,14 @@ void readfile(string file)
} }
} }
void writefile(string file) void writefile(string file, string text)
{ {
string line; string line;
ofstream myfile; ofstream myfile;
myfile.open(file,std::ios_base::app); myfile.open(file,std::ios_base::app);
if (myfile.is_open()) if (myfile.is_open())
{ {
myfile << "hallo\n"; myfile << text+"\n";
} }
myfile.close(); myfile.close();
} }

Binary file not shown.

View File

@ -1,4 +0,0 @@
hallo
hallo
hallo
hallo