Предмет: Информатика,
автор: asdasedqwdwqd
Задача на с++
Дан файл. Удалить из него третью строку.
Результат записать в другой файл.
Ответы
Автор ответа:
0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <iterator>
using namespace std;
int main()
{
vector<string> str;
string text;
ifstream fin("a.txt");
while (getline(fin, text)) {
str.push_back(text);
}
fin.close();
str.erase(str.begin() + 2);
ofstream fout("b.txt");
copy(str.begin(), str.end(), ostream_iterator<string>(fout, "\n"));
fout.close();
system("pause");
return 0;
}
#include <fstream>
#include <string>
#include <vector>
#include <iterator>
using namespace std;
int main()
{
vector<string> str;
string text;
ifstream fin("a.txt");
while (getline(fin, text)) {
str.push_back(text);
}
fin.close();
str.erase(str.begin() + 2);
ofstream fout("b.txt");
copy(str.begin(), str.end(), ostream_iterator<string>(fout, "\n"));
fout.close();
system("pause");
return 0;
}
Похожие вопросы
Предмет: Алгебра,
автор: kitsyyne
Предмет: Информатика,
автор: ulanaguluk554
Предмет: Биология,
автор: anastasiapasecna
Предмет: Математика,
автор: Аноним