Having a hard time here, Im not great with pointers and arrays yet, can anyone tell me how to properly pass a char array, i thought this was right but the compiler is complaining with:
I know the bubble sort is incomplete, i just wanted to quickly test the passing values when this error stopped me.
SORT.CPP: In function ‘int main()’:
SORT.CPP:28: error: cannot convert ‘char (*)[15]’ to ‘char*’ for argument ‘1’ to ‘void bub_sort(char*, int)’
#include <iostream>
#include <fstream>
using namespace std;
char test_ar[6][15] = { 'c','d','b','a','e'};
// swap two values
void swap(char *x,char *y);
void bub_sort(char*, int);
void bub_sort(char* char_array, int length) {
int i,k;
for (k=0;k<=length;k++) {
for (i=0;i<=length;i++) {
if (char_array[i+1] > char_array[i]) {
cout << "char_array[i+1] is bigger: " << char_array[i+1] << " than " << char_array[i];
} // end char
}
}
}
int main() {
bub_sort(test_ar,5);
return 0;
}
Thanks in advance.