how to reverse a string without changing its place in c ? eg - input: welcome to codechef website output: emoclew ot fehcedoc etisbew
I think you meant rerversing words in a string. If words are split only by spaces the function would look like this: Code: void reverse_words(char *str) { char *end, *ptr = strtok(str, " "); while (ptr != NULL) { strrev(ptr); end = ptr + strlen(ptr); ptr = strtok(NULL, " "); if (ptr != NULL) { *end = ' '; } } }