내 .txt
파일에 출력이없는 것 같습니다. 나는 미래에 텍스트 파일 아래에 추가하고 싶습니다.내 txt 파일에 글을 쓰고 아래에 텍스트를 추가하는 방법
std::ofstream myfile(filename.str(), std::ofstream::out | std::ofstream::app);
그리고 너무 그 파일을 엽니 다 ofstream
의 객체를 생성하는 동안 파일 이름을 통과, 다시 .open
를 호출 할 필요가 없습니다으로
using namespace std;
int main()
{
string month;
int year;
stringstream filename;
cin >> month;
cin >> year;
filename << "Expenses_" << month << "_" << year << ".txt";
ofstream myfile(filename.str());
myfile.open(filename.str());
myfile << "Hello World!";
myfile.close();
return 0;
}
[모든 좋은 초보자의 책] (http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) 정보를 가지고 있어야 그것에 대해. [C++ 입출력 시스템에 대한 좋은 참고서] (http://en.cppreference.com/w/cpp/io)도 도움이 될 것입니다. –
http://www.cplusplus.com/reference/fstream/ofstream/open/ – macroland