Palindrome char array function

I need to create a program that allows user to define size of a char array in the main function. Then call a function createArray to create a user input char array. Then determine if the user entered char array is a Palindrome.


So far I have the following code, which allows user to enter a char array. However, I cannot figure out how to reverse it and determine if it is a palindrome. I believe I have also messed up with defining the char array because it only has scope in the function (not in main).

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
  #include <iostream>

using namespace std;

void createArray(int);


int main()
{
int size;
cout << "Enter the size of the array: ";
cin >> size; 
char array[size];
createArray(size);
reverse(array[size]);

return 0;
}

void createArray(int size)
{
	char array[size];
	for (int i = 0; i < size; i++)
	{
		cout << "Enter character for element " << (i + 1) << ": ";
		cin >> array[i];
	}
}


Thanks in advance.
Topic archived. No new replies allowed.