Advertisement
Mazamin

Reverse Word And Print

Dec 15th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #define MAX_LEN 128
  5.  
  6. int reverse_word_and_print(char (*), int);
  7.  
  8. main(){
  9.     int w=0, rv;
  10.     char words[MAX_LEN][MAX_LEN];
  11.     do{
  12.         scanf("%s", words[w]);
  13.         rv=reverse_word_and_print(words[w], strlen(words[w]));
  14.         w++;
  15.     }while(rv==0);
  16.     return 0;
  17. }
  18.  
  19. int reverse_word_and_print(char (*stringPtr), int size){
  20.     int i;
  21.     i=size;
  22.     if((strcmp("stop", stringPtr))!=0){
  23.         while( i --> 0 )
  24.             putchar(stringPtr[i]);
  25.         printf(" %d\n", size);
  26.         return 0;
  27.     }
  28.     else
  29.         return 1;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement