I'm teaching myself C, and wrote this string reverse function. I cannot figure out why it is crashing...
#include <stdio.h>
void ReverseString(char *inStr, int length);
void ReverseString(char *inStr, int length)
{
char temp;
int j=length;
int i=0;
while( i != j)
{
temp = *(inStr+i);
*(inStr+i) = *(inStr+j);
*(inStr+j) = temp;
i++;
j--;
}
}
int main()
{
char mike[] = "Hello";
ReverseString(mike, 5);
printf("%s", mike);
}