Advertisement
Guest User

cs50 pset2 readability

a guest
Nov 2nd, 2022
911
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. int count_words(string text)
  2. {
  3. int words = 0;
  4. int l = strlen(text);
  5. for (int j = 0; j < l; j++)
  6. {
  7. if (isspace(text[j]) != 0)
  8. {
  9. words++;
  10. }
  11. }
  12. if (l >= 1)
  13. {
  14. words += 1;
  15. }
  16. return words;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement