SHARE
TWEET

help

a guest Feb 18th, 2020 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int words_3char(char *str){
  2.     int i;
  3.     int cnt = 0;
  4.     int words = 0;
  5.    
  6.     for (i = 0; str[i] != '\0'; i++){
  7.         if (str[i] != ' ' && str[i] != '\0'){
  8.             cnt++;
  9.         } else if (cnt == 3) {
  10.             words++;
  11.             cnt = 0;
  12.         } else {
  13.             cnt = 0;
  14.         }
  15.     }
  16.     return words;
  17. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top