Hello

My task is to writ a function that takes in a char array & the array size as its parameters & reverses the array contents. I cannot use another array to reverse the contents.

I am using insert & erase function to reverse the array, although I dont know which library I am meant to use & the correct syntax of the commands(insert & erase)?

Libraries:

dequeue
list
map
string
set
multimap

Any Advice?

#include <iostream>

using namespace std;

void reverse (char a[], int n);

int main() {

	char x[5] = {'a', 'b', 'c', 'd', 'e'};

	reverse(x,5);

	return 0;
}

void reverse (char a[], int n) {

	for (int i=0; i<n; i++) {
		insert(a[i],a[n-i]);  // is this the correct sytax??
		erase(a[n-i]);        // or should it be a[i].insert();
	}

What happens if you just swap the first and last elements of the array?

Um, I not quite sure what you mean, but what I am trying to do is reverse the contents in an array

eg
from this: a,b,c,d,e

to this: e,d,c,b,a

So
abcde
becomes after 1 step
ebcda

Move towards the middle, and repeat....