Reverse words in a string by C

An example to reverse the word in a string.

Source

#include <stdio.h>

char* strrevw(char* string){
    char* s=string;
    char* e=s;
    char  ch;
    char *ws,*we;
    while(1){
        if(*e==' ' || *e=='\0'){
            ws=s;
            we=e-1;            
            while(ws<we){
                ch=*ws;
                *ws++=*we;
                *we--=ch;
            }
            if(*e=='\0')
                break;
            s=e;
            while(*++s==' ');
        }
        e++;
    }
    return string;    
}

int main(){
    char a[]="123  1234   12345";

    printf("%s\n",a);
    printf("%s\n",strrevw(a));
    return 0;
}