さゆがC/C++の宿題を片付けるの 36代目
■ このスレッドは過去ログ倉庫に格納されています
0247デフォルトの名無しさん
NGNG#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cstdlib>
int main()
{
std::ifstream ifs("a.txt");
std::string str;
std::vector<std::string> vs;
if (!ifs) {
std::cerr << "a.txtがありません。" << std::endl;
std::exit(1);
}
while (std::getline(ifs, str))
vs.push_back(str);
ifs.close();
std::ofstream ofs("a.txt");
if (!ofs) {
std::cerr << "a.txtのオープンに失敗しました。" << std::endl;
std::exit(1);
}
■ このスレッドは過去ログ倉庫に格納されています