samir82show

word length counter

Nov 1st, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include<stdio.h>
  2. //this is private library holding the horzental and vertical histogram functions
  3. #include "/app/oracle/11.2.0/grid/clang/mylib/priv_lib.h"
  4. #define ON 1
  5. #define OFF 0
  6. #define SIZE 100
  7. void VertHisto(int* array,int size);
  8. void HorzHisto(int* array,int size);
  9. int main()
  10. {
  11. int c, i, arr[SIZE];
  12. int nc;
  13.  
  14. short s = ON;
  15. for(i = 0;i < SIZE;i++)
  16. arr[i] = 0;
  17. i = nc = 0;
  18.  
  19. while((c = getchar()) != EOF) {
  20. if(c == ' ' || c == '\t' || c == '\n') {
  21. if(s == ON) {
  22. s = OFF;
  23. arr[i] = nc;
  24. nc = 0;
  25. i++;
  26. }
  27. } else {
  28. s = ON;
  29. nc++;
  30. }
  31. }
  32. HorzHisto(arr,SIZE);
  33. printf("\n");
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment