How would I write this?
I am new to C++ and am trying to write this but don't really have any idea how?
I tried to outline it first so I could do it step by step, but now that I have outlined it I am stuck one how to do it?
This is my outline.
int main( )
{
declare el, pl as strings to store an English line, Pig Latin line;
prompt for and get English line (use gets);
while (line is not equal to “!!!”)
{
translate(el, pl);
output Pig Latin line to the screen and to a file;
prompt for and get English line (use getline);
}
system("pause");
return 0;
}
void translate(const char el[ ], char pl[ ])
{
declare ew, pw as c-strings to store an English, Pig Latin word;
declare ep, pp as integer variables that tell the current positions in el, pl;
initialize current positions ep, pp to be the beginning of el, pl, i.e. initialize them to 0;
while (not at end of el)
if (character at current position in el is a letter)
{
extract word from el that starts from current position and store in ew;
translate word ew to Pig Latin and store in pw;
copy pw at current end of pl;
make sure ep, pp are now set to positions just past the word;
}
else
{
copy character unchanged to current position in pl;
increment ep, pp;
}
Null terminate the string pl;
}
can someone walk me through how I would do each of these steps ... or maybe just some of them piece by piece so I can understand how to do it.