Hello,
I am writing a program to determine if an inputted phrase or word is a palindrome. I am to use a separate function to input the string and another to check and see if it is a palindrome or not and return true or false. The first is a void function and the second, a bool. I have the array declared in main. After the first function (void) executes and the user enters the words, the output of the array in main is a line of smiley faces. This is only happens when the function writes to the array. When the array is declared and initialized with some letters, it displays fine in main. What is my issue here?
Here is the void function to get the user input and write it to a file. MAX = 20.
void getSent(char array[MAX])
{
char ch;
int index=0;
cout << "Enter the palindrome: ";
while ((ch = cin.get() != '\n') && (index < MAX-1))
{
array[index] = ch;
index ++;
}
array[index] = '\0';
cin.ignore (1000, '\n');
}
Thanks,
Mitch