How to fwrite a char array pointer?

I have a char array called: char buffer[256] made up of characters read from a txt file using fread.
Then I used strtok and strncmp to bubble-sort all the elements and had to place them into the pointer char *ptr. Of course it works great when I just use for(int i=0;i<numberofelements;i++){printf("%s", ptr[i]);}, it prints out all the elements in a sorted fasion. However, now I want to overwrite the un-sorted txt file with the newly sorted data. When I try to use fwrite and use the *ptr, the file is corrupted and filled with junk data. Any suggestions?
Topic archived. No new replies allowed.