Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- int main(int argc, char *argv[])
- {
- setlocale(LC_ALL, "Rus");
- srand(time(NULL));
- //для записи в файл используется класс ofstream
- std::ofstream fs;
- std::string path = "file.txt";
- fs.open(path, std::ofstream::app);
- if (fs.is_open())
- {
- for (int i = 0; i < 5; i++)
- {
- std::cout << "Скажите что-нибудь: ";
- std::string inputFile;
- std::cin >> inputFile;
- fs << "\n";
- fs << inputFile;
- }
- std::cout << "Готово!";
- }
- fs.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement