Write a c++ program that will read in, from a file entitled "word.txt", an unknown
number of single words (no spaces ). The program will then print out the
word, move 2 tabs to the right, display the word with the first letter
removed, move 2 tabs to the right, display the adjusted word with a
percent sign ( % ) inserted between the 3rd and 4th characters, move 2
tabs to the right, and finally display the new adjusted word with a pound
sign ( #) replacing the final letter of the word. Look at my code below and tell me what i'm doing wrong.
Output is to both the screen and the printer.
Example of output:
backups ackups ack%ups ack%up#
My infile is:
rumpler
harmony
gidgets
fromage
squares
pancake
lexicon
piglets
singles
program
printer
happily
offices
windows
express
poisons
The code that I have thus far is:
#include <iomanip>
#include <cmath>
#include <fstream>
#include <string>
#include<string>
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
ifstream infile;
ofstream outfile;
infile.open ("word.txt");
outfile.open ("wordOutput");
string phrase;
while (getline(infile,phrase,'\n'))
{
phrase.erase(0,1)
cout<<phrase<<endl;
phrase.insert(4,"%");
cout<<phrase<<endl;
phrase.replace(7,"#")
cout<<phrase<<endl;
}
return 0;
}