Задача на с++
Дан файл. Удалить из него третью строку.
Результат записать в другой файл.
Ответы на вопрос
Ответил clinteastwood2
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;
}
Новые вопросы
География,
2 года назад
Математика,
8 лет назад
Химия,
8 лет назад
Математика,
9 лет назад
Алгебра,
9 лет назад