I wrote this function to reverse a string in C, but when switching characters in the string the program crashes. I have no idea what's causing it, so any help would be appreciated.
void reverse(char s[])
{
char c;
int i;
int j;
for (i = 0, j = (strlen(s) - 1); i < j; i++, j--)
{
c = s[i];
s[i] = s[j]; //An error occurs here
s[j] = c;
}
printf("%s", s);
}
main()
{
reverse("Example");
}