Help with Program (error problems)

Hello! I am creating Palindrome problem and I am getting these two errors:

recursion.cpp: In function âint main()â:
recursion.cpp:75: error: âstrlenâ was not declared in this scope
recursion.cpp:82: error: âgetchâ was not declared in this scope

Here is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<iostream>
  #include<cmath>
  #include<string>
 
  using namespace std;
 
 
  bool Palindrome(int first, int last, char inputString[]);
 
  int main()
  {
    int first = 0;// first index for array
    int last = 0;// last index for array
    char inputString[100];//initialize size of array
 
 
    cout << "This program determines whether the word"
         << endl
         << "or sentence entered by user is a palindrome."
         << endl;
 
    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.";
      else
           cout << "Input is not classifed as a palindrome.";
 
        getch();
 
          return 0;
  }
 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)
       return true;
 
    //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])
       return false;

   //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.
   else if (inputString[first] == inputString[last])
   {
      return Palindrome((first+1),(last-1),inputString);
   }
 }



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).
Topic archived. No new replies allowed.