How to write a program to create a txt file and write five lines to it | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to write a program to create a txt file and write five lines to it

19th Feb 2021, 12:17 PM
Rishikesh Shrigadi
Rishikesh Shrigadi - avatar
3 Answers
19th Feb 2021, 12:40 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
+ 1
Here you can see how can be done it: https://code.sololearn.com/cPB5asMrV1rw/?ref=app
19th Feb 2021, 1:09 PM
JaScript
JaScript - avatar
0
If using C++, you can achieve this by including the 'fstream' header file, and using it's function 'ofstream("filename.txt");' in your main method to create the txt file and then use the object to write the 5 lines inside a while loop.
19th Feb 2021, 12:46 PM
Rishabh Mehta
Rishabh Mehta - avatar