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();
}