사용자 입력을 기반으로 파일을 여는 프로그램을 만들려고합니다. Here`s 내 코드 :사용자 입력을 기반으로 파일 열기 C++
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
string filename;
ifstream fileC;
cout<<"which file do you want to open?";
cin>>filename;
fileC.open(filename);
fileC<<"lalala";
fileC.close;
return 0;
}
그러나 나는 그것을 컴파일 할 때, 그것은 나에게이 오류 제공 :
이[Error] no match for 'operator<<' (operand types are 'std::ifstream {aka std::basic_ifstream<char>}' and 'const char [7]')
사람이이 문제를 해결하는 방법을 알고 있나요을? 감사합니다 ...
봐 :
그래서 올바른 코드는 다음과 같다. –
... 대신'std :: ofstream'을 사용하십시오. –