I need to swap two characters with pointers, but when I run this code, the program will crash.
int main(){ char *s1 = "string1"; swap(st,(st+1)); return 0; } void swap(char * const ptr1, char * const ptr2){ char temp = *ptr1; *ptr1 = *ptr2; *ptr2 = temp; }
source share