このプログラムの変数 "read"は、関数を介して渡す必要があり、そのデータ型がわかりません。私はhttp://www.cplusplus.com/reference/fstream/ifstream/ifstream/ とhttp://www.cplusplus.com/reference/fstream/ifstream/を使用しましたが、私は何かを見つけるのに苦労しています、これはちょうど不可能ですか?std :: ifstreamデータ型?
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();
}
「何かを見つけるのに苦労している」とはどういう意味ですか?文字通り、 'read'オブジェクトは' ifstream'型であり、あなたは_ifstream_の参照にリンクしています。何が問題ですか? –
私は変数を関数に渡して渡す必要があり、どのデータ型がわからないのですか – ToastehMonkey
そこにはちょうどいいと言われています。これはトロールですか? @doctorloveいいえではありません –