#include <stdio.h>
#include <string.h>
void reverse_char_array(char * first, char * last) {
    while (first != last && first != --last) {
        *first ^= *last;
        *last ^= *first;
        *first++ ^= *last;
    }
}
void reverse_string(char * sentence) {
    reverse_char_array(sentence, &sentence[strlen(sentence)]);
}
void reverse_word(char * sentence) {
    char * end_s = &sentence[strlen(sentence)], * end_w = NULL;
    while (end_w != end_s) {
        if (!(end_w = strchr(sentence, ' '))) end_w = end_s;
        reverse_char_array(sentence, end_w);
        sentence = end_w + 1;
    }
}
int main(int argc, char ** argv) {
    char sentence[] = "Shall we all die?  We shall die all!  All die shall we?  Die all we shall!";
    reverse_string(sentence);
    reverse_word(sentence);
    printf("%s\n", sentence);
    return 0;
}