Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to write a program that opens a text file and copies its content and then

ID: 3634505 • Letter: I

Question

I need to write a program that opens a text file and copies its content and then encodes it by moving the first character of every word/string and putting it at the end of the word/string. For example, if the word was "apples" it would rewrite it as "pplesa". If the first character was capital, the 2nd word that goes in front has to be capitalized, such as "Apples" turning into "Pplesa". Then after this I need another function that opens the encoded.txt and decodes it by doing the opposite of the encode and changes everything back to normal.

The important detail: I can't use arrays for this assignment.

Explanation / Answer

Dear, /*This program compiled using Visual C++ 2010. To compile this progrma in in Visual C++ 2010 include stdafx.h header file*/ #include "stdafx.h" #include //needed for file operations #include //needed for I/O operations #include //needed for string operations using namespace std; //function to read file void fileRead(string); //function main void main() { string filename; coutfilename; //calling function to read file fileRead(filename); //to halt the system system("Pause"); } //declaration of function to read file void fileRead(string str) { string astr,estr; char ch,ch2,rchar; int s; //variable to hold a input file ifstream infile; //variable to hold a output file ofstream decode, encode; //opening a input file infile.open(str); //opening a output file decode.open("decode.txt"); encode.open("reencode.txt"); //check the file exist or not if (!infile.is_open()&&!decode.is_open()) cout