Possible Duplicate:
Why do I get a segmentation fault when writing to a string?
If I have a pointer and I know the indexes of both the chars, how would I swap the chars(I didn't actually allocate an array)
i.e.
char *str = "hello"
and I know and I wanted to swap the 'h' and 'o' which is index 0 and 4, and then return the pointer as well.
I'm used to doing the convention of
temp = array[i];
array[i] = array[j];
array[j] = temp;