私のコードをコンパイルすることはできません。なぜなら、エラー16行目に「エラー:呼び出しに一致する関数がありません。私はファイルを読んで、すべての母音を出力ファイルに書き込むと仮定しています。これにC++の入力ファイルと出力ファイルへの書き込み
inputfile.open(filename);
:この
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
string filename; // to hold the file name
ifstream inputfile; // input to a file
// Get the file name
cout << "Enter a file name: ";
cin >> filename;
// Open the file
inputfile.open(filename); // LINE 16
char vowel; // to store the vowels
ofstream outputfile; // to write to the file
// open file
outputfile.open("vowels_.txt");
while(inputfile.get(vowel)){
//If the char is a vowel or newline, write to output file.
if((vowel == 'a')||(vowel == 'A')||(vowel =='e')||(vowel =='E')||(vowel =='i')||(vowel =='I')||(vowel =='o')||(vowel =='O')||(vowel =='u')||(vowel =='U')||(vowel =='\n') && !inputfile.eof())
outputfile.put(vowel);
}
inputfile.close();
outputfile.close();
}
ライン17空白行です。 – immibis
@immibis line 16、申し訳ありません。 –
私はそれがopen()コールだと思います。 'inputfile.open(filename.c_str());' – Rene