I want help regarding a function which you call from main that reverse text. However, the program works, well "more or less" but it crashes. Here is how code looks
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void reverse(char * array, int numberOfChars) {
int begin = 0;
int end = 0;
char temp;
end = strlen(&array) - 1;
printf("%s", &array);
while (begin < end) {
temp = array[begin];
array[begin] = array[end];
array[end] = temp;
begin++;
end--;
}
}
int main() {
reverse('supm', 4);
return(0);
getchar();
}
The string gets reversed to mpus, but then crashes, apparently it seems also like the arrays can only take in 4 characters, if i change it to 5 and the integer value to 5, it won't work at all. Any help would be appreciated.