Кто-нибудь знает, как обрезать этот C ++ в .txt файл?

#include <fstream>
#include <iostream>

using namespace std;

int main()
{
char filename[] = "text.txt";
std::fstream file;

file.open(filename, ios::out | ios::trunc);
file << "This text will now be inside of " << filename << std::endl;
file.close();

file.open(filename, ios::in);
std::string line;
std::getline(file, line);

std::cout << line << std::endl;
}

Скриншот

Достаточно ли ясно, может ли char filename[] = text.txt а показанный файл text.txt будет как-то урезан?
Я вижу код выше и файл text.txt на изображении, показанном выше, и я не знаю, почему он не изменится. Если файл text.txt недоступен из .cpp в изображении.

1

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector