The point of the code void rotate_in_place(char *str, unsigned int disp) is to take in a string and integer and rotate each character of the string by the disp integer.
When running my code I keep getting a Segmentation fault.
Coding Language: C
I have implemented my code as follows:
void rotate_in_place(char *str, unsigned int disp)
{
  int i=0;
  if(disp<0 || disp>2600)
    printf("Illegal Input");
  else
    disp= disp%26;
  for(i =0; i<strlen(str); i++){
    if(str[i]>='a' && str[i]<='z'){
      str[i]= str[i]+disp;
      if(str[i]>'z')
    str[i]=str[i]-'z'+'a'-1;
    }
    else if(str[i]>='A' && str[i]<='Z'){
      str[i]= str[i]+disp;
      if(str[i]>'Z')
        str[i]=str[i]-'Z'+'A'-1;
    }
    else
      str[i]=str[i];
  }
  str[i]='\0';
  printf("%s", str);
}
int main(){
rotate_in_place("Hello World", 5);
rotate_in_place("Hi", 13);
rotate_in_place("World", 42);
return 0;
}
I am not yet done with the code, so it may be incorrect but I cannot run it without getting a Segmentation fault.
Is there any reason why I keep getting this Segmentation fault, is there a memory leak in my code?