read a word from the file, draw a line in the space between them, and paste it into another file | SoloLearn: Learn to code for FREE!

0

read a word from the file, draw a line in the space between them, and paste it into another file

11/23/2017 6:21:09 AM

Daniyar

1 Answer

New Answer

+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]