I need to swap two characters by pointers but when I run this code,the program crashes.
int main(){
    char *s1 = "string1";
    swap(st,(st+1));
    /* BUT THIS CODE WORKS - Whats the problem?
     * char s1[] = "string1";
     * swap(s1,&s1[1]);
     */
    return 0;
}
void swap(char * const ptr1, char * const ptr2){
    char temp = *ptr1;
    *ptr1 = *ptr2;
    *ptr2 = temp;
}
 
     
     
     
    