File IO of String Data

Understand the file handling of strings data in C++.

Challenge

Write a program to write strings into a file called STRINGS.TXT. Read the same file back and display the contents read on the screen.

Sample run

root@educative:/usr/local/educative# g++ main.cpp 
root@educative:/usr/local/educative# ./a.out

You should be enthusiastic about your future
That is where you are going to spend the rest of your life

root@educative:/usr/local/educative# cat STRINGS.TXT
You should be enthusiastic about your future
That is where you are going to spend the rest of your life

Coding exercise

Your job is to write the code for writing and reading to the file in the main( ) function.

Get hands-on with 1400+ tech skills courses.