/
MaximGuliverDev
/
task1
Обзор
Документация
Войти
/
MaximGuliverDev
/
task1
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
work_with_files_hw.cpp
38 строк
847 B
MaximGuliverDev
upload files
27 фев 2025, 21:04
27 фев 2025, 21:04
6e9c12d
Код
Авторство
О чём код?
#include <iostream> #include <fstream> #include <string> int main() { setlocale(LC_ALL, "Russian"); //запись в файл /*std::ofstream ofile("testfile.txt"); if (ofile.is_open()) { ofile << "Hello World!! " << std::endl; ofile << "Second string " << std::endl; } ofile.close();*/ std::ifstream ifile("testfile.txt"); if (ifile.is_open()) { std::string data{}; //////////Чтение до пробела while (ifile >> data) { std::cout << data << std::endl; } /////////Чтение строки целиком //while (std::getline(ifile >> std::ws, data)) //{ // std::cout << data << std::endl; // } } ifile.close(); return 0; }