+ 16
//===============================================
// CodeName : file R/W and string
// Done for : Daniyar
// By : Babak Sheykhan
// URL : www.sololearn.com/Discuss/876050/
// Date : Nov 23, 2017
// Note : Program has no output on SL
//===============================================
#include <fstream>
#include <string>
int main() {
std::ofstream fout;
std::string str1 = "Hello";
std::string str2 = "";
// Create a file containing the word "Hello" to our experiment
fout.open("MyFile_1.txt");
fout << str1 << std::endl;
fout.close();
// reading from our newly created file
std::ifstream fin;
fin.open("MyFile_1.txt");
fin >> str2;
fout.close();
// Create a new text file to writing new manipulated string
// loop through the second string and put a line after each letter into file
fout.open("MyFile_2.txt");
for (auto const i : str2) fout << i << "_";
fout.close();
}
[https://code.sololearn.com/clndeX81aUk0]