hello my output is wrong- i want to have "hello how are you" turn into having the fist character put at ends of words and 'a' and 'y' added at end basically pig latin. I want all my variables and loop

#include <iostream>

#include <cstring>

using namespace std;


int main()

{

//set vars

const int size =81;

char inStr[size];

char outStr[size + 20 ] = "";

int currentInIndex = 0;

int currentOutIndex = 0;

char firstChar = 0;


cout << " Enter a sentence and I will translate it to Pig Latin: ";

cin.getline(inStr,size);

int length = strlen(inStr);

//test for errors

if (length>size)

{

cout << "Error";

return 42;

}


firstChar = inStr[0];


//parse through arrays


for (currentInIndex =0; currentInIndex<length+1; currentInIndex++)

{

//Beg of word (just storing character)

if (firstChar == 0 && isalpha(inStr[currentInIndex]))

{

firstChar = inStr[currentInIndex];

}

//Middle of word

else if (isalpha(inStr[currentInIndex]) && firstChar != 0)

{

outStr[currentOutIndex++] = inStr[currentInIndex];

}

//End of word

else

{

if (firstChar != 0)

outStr[currentOutIndex++] = firstChar;

outStr[currentOutIndex++] ='a';

outStr[currentOutIndex++] ='y';

}

//space

outStr[currentOutIndex++] = inStr[currentInIndex++];

firstChar = 0;

}

outStr[currentOutIndex] = '\0';

cout << outStr ;

return 0;

}



}