bool Palindrome(int first, int last, char inputString);
int first = 0;// first index for array
int last = 0;// last index for array
char inputString;//initialize size of array
cout << "This program determines whether the word"
<< "or sentence entered by user is a palindrome."
cout << "\n\nPlease enter a word or phrase: ";
cin >> inputString;//receive input from user
last = strlen(inputString);//store input into character array
if (Palindrome(first,last - 1,inputString)== true)
cout << "Input is classified as a palindrome.";
cout << "Input is not classifed as a palindrome.";
bool Palindrome(int first, int last, char *inputString)
//if the next first index is greater than the next last index
//program concludes that all the elements in array have been compared
//and therefore input should be a palindrome retuned as true.
if (first > last)
//if next first element and next last element are not the same
//therefore word is not a palindrome returned as false
if (inputString[first]!= inputString[last])
//if next first element and next last element are same
//call Palindrome function again, increment first element by one
//decrement last element by one to compare if those two elements
//in array are equal.Continue this process until next first element
//and next element are not equal.
elseif (inputString[first] == inputString[last])
How can I fix the errors? I know they are small just some help thank you. I tried making them variables and it did not work.
strlen and such are library functions defined for you, defining them as variables is wrong. The errors mean that the compiler sees are are trying to use those functions but can't find them defined anywhere. Hence, you must include the correct file that contains the definitions.
They are inside the <cstring> header file (note the c in front of string).