I am new in C and am encountering some issues. Im trying to reverse a given string in C and somehow get a segmentation fault while doing it
#include <stdio.h>
#include "my_revstr.h"
int my_strlen(char const str[]){
int i = 0;
int count = 0;
while (str[i] != '\0'){
count++;
i++;
}
return count;
}
void my_revstr(char str[]) {
int len = my_strlen(str);
char temp;
char* ptr = str;
char test;
for (int i = 0 ; i < len /2; i++) {
ptr += ptr[i];
str[i]= str[(len/2)-1];
}
printf("%s", str);
}
int main() {
my_revstr("ABCDE");
}