Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #include <stdio.h>
- #include <stdlib.h>
- char house[]="this is a test string";
- int main(){
- int len = strlen(house);
- char *buff = (char*)malloc(len+1);
- memset(buff,'\0',len * sizeof(char)+1);
- char* end = (house+len);
- char* beg = (house+len);
- int j = 0;
- for(int i = 0; i < strlen(house)+1; i++){
- beg--;
- if(*beg == ' ' || beg < house){
- char* tmp = beg;
- tmp++;
- while(tmp != end){
- buff[j++] = *tmp++;
- }
- buff[j++]=' ';
- end = beg;
- }
- }
- printf("%s\n",buff);
- return 0;
- }
Add Comment
Please, Sign In to add comment