This is not a good idea:
Code:
void reverse_words(char *s) {
char b[100], *t, *z;
int c = 0;
What I mean is that you declared five variables, all of which having single character names. Such variable names are common for loop and array indices, perhaps for variables in a very small scope such that their purpose and meaning is blatantly obvious, and sometimes for certain domain-specific purposes, but otherwise they tend to be poorly chosen because they are not descriptive.
Since you seem to be willing to work with pointers, I suggest an entirely in-place version of what you are trying to do, inspired by the loop structure that you outlined:
Code:
void reverse_words(char *text) {
char *word_start = text;
char *word_end;
while (*word_start != '\0') {
/* use a loop to increment word_start until it points to a character
that is a '\0', or is neither whitespace nor a special character
... */
word_end = word_start;
/* use a loop to increment word_end until it points to a character that
is a '\0', whitespace, or a special character
... */
reverse_word(word_start, word_end);
word_start = word_end;
}
}
void reverse_word(char *word_start, char *word_end) {
/* reverse the word using the start and end pointers, keeping in mind that
word_end points to the character immediately after the word's last
non-special character, so you should not alter what it points to;
one way to do this is to first decrement word_end, then loop to
increment word_start and decrement word_end until word_start is no
longer less than word_end, swapping characters as you go
... */
}