Die Variable "lesen" in diesem Programm muss durch eine Funktion übergeben werden und ich weiß nicht, um welchen Datentyp es sich handelt. Ich habe http://www.cplusplus.com/reference/fstream/ifstream/ifstream/ und http://www.cplusplus.com/reference/fstream/ifstream/ verwendet, aber ich habe Mühe, etwas zu finden, ist das einfach nicht möglich?std :: ifstream-Datentyp?
int main()
{
string line = " ", ans = " ", ans2 = " ", data = " ";
int i = 0, j = 0;
cout << "What file do you want to read? : ";
cin >> ans;
cout << "What do you want the new file to be called? : ";
cin >> ans2;
ifstream read(ans.c_str());
for (i = 0; !read.eof(); i++)
{
read_function(line, read);
write_function(line, ans2);
}
return 0;
}
string read_function(string line, string read)
{
getline(read, line, ' ');
cout << line;
}
void write_function(string line, string ans2)
{
ofstream write(ans2.c_str(), ios::app);
write << line;
write.close();
}
Was meinst du mit "kämpfen um etwas zu finden"? Es sagt genau dort, dass das Objekt 'read' vom Typ' ifstream' ist, und du bist gerade mit der Referenz für _ifstream_ verbunden. Was ist das Problem? –
Ich muss die Variable durchlesen eine Funktion übergeben und ich weiß nicht, welcher Datentyp es ist – ToastehMonkey
Es sagt genau dort. Ist das ein Troll? @doctorlove nein es ist nicht –