I'm working on a homework assignment that I've worked out successfully in each function except the last. My last function breaks/overflows the output of all my previous code. I did some research, and I'm thinking it is an overflow issue with my pointers, but I'm honestly stuck and unsure. I apologize if I've posted too much code, I cut out what I thought would be relevant to understanding the issue. Thank you for your time.
main() {
// Declarations for string arrays and size varible.
constint SIZE = 81; // Sentence character cap is 80, the +1 holds the null terminator
char sentence[SIZE];
char ecnetnes[SIZE]; // muahahahaha
// Populating sentence array
cout << "Input a sentence that is no longer than 80 characters, spaces included as characters." << endl;
cin.getline(sentence, SIZE);
// Calling the find length function to determine true length of string array
int length = findLength(sentence);
// Calling conver caps function to capitalize the entire string array
// Declaring pointer to pass the captilization changes made during function call
char *sentencePTR = sentence;
convertCaps(sentencePTR, length);
// Calling count letter function to count the number of letter within the string array
int letters = countLetters(sentence);
//Calling count vowels function to count and return the number of vowels within in the string array
int vowels = countVowels(sentence);
// Calling function to count and return the number of words within the string array
int words = countWords(sentence);
// Calling count conso function to count and return the number of consonants within the string array
int conso = countConso(sentence);
// Calling reverse string function to fill a 2nd string with the contents of the first string, then reverse the contents
// Creating another pointer for editing the second char array.
char *ecnetnesPTR = ecnetnes;
reverseString(ecnetnesPTR, length, sentence);
// function that is causing issues
void reverseString(char* ptr, int size, char str[]) {
int index = size-1;
int i = 0;
while (ptr[i] != '0') {
ptr[i] = str[index];
index--;
i++;
}
}