Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- void words(char string[]);
- static char *reverse(char string[], int start, int end);
- void print(char *string, int start, int end);
- int main(void){
- words("no way.");
- return 0;
- }
- void print(char *string, int start, int end){
- int x;
- for(x=start; x<end; x++){
- printf("%c", string[x]);
- }
- printf("\n");
- }
- void words(char string[]){
- int x, y=0;
- int length=(int)strlen(string);
- string=reverse(string, 0, length-1);
- printf("here it is:");
- print(string, 0, length);
- for(x=0; x<=length; x++){
- if((x==(length))||(string[x]==' ')){
- string=reverse(string, y, x-1);
- printf("%s\n", string);
- y=x+1;
- }
- }
- print(string, 0, (int)strlen(string));
- }
- static char *reverse(char string[], int start, int end){
- int length=(int)strlen(string);
- int i, j;
- static char newstring[50];
- for(i=start, j=end; i<length; i++, j--){
- newstring[i]=string[j];
- }
- return newstring;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement