1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
|
#include <iostream>
#include <string>
#include <cstdio>
#include <fstream>
#include <cstdio>
using namespace std;
int main()
{
string dateiname_erstellen = "test.txt";
ofstream datei_erstellen;
datei_erstellen.open(dateiname_erstellen.c_str(), ios_base::out);
datei_erstellen << "1" << endl << "2" << endl << "3" << endl << "4" << endl << "5" << endl << "6" << endl << "7" << endl << "8" << endl <<"9" << endl << "10" << endl << "11" << endl << "12" << endl << "13" << endl << "14" << endl << "15" << endl;
fflush(stdin);
getchar();
string zeile[20];
int loop;
string dateiname = "test.txt";
string text_neu1 = "hallo";
ifstream datei_lesen;
datei_lesen.open(dateiname.c_str(), ios_base::out);
for(loop = 0; loop < 20; ++loop)
{
datei_lesen >> zeile[loop];
}
for(loop = 0; loop < 20; ++loop)
{
cout << zeile[loop] << endl;
}
fflush(stdin);
getchar();
zeile[12] = text_neu1;
ofstream datei_schreiben;
datei_schreiben.open(dateiname.c_str(), ios_base::out);
for(loop = 0; loop < 20; ++loop)
{
datei_schreiben << zeile[loop] << endl;
}
return 0;
} |