Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. int main(int argc, char * argv[])
  2. {
  3. char *w;
  4. char c;
  5. char **words;
  6. char buf[64];
  7. int i;
  8. int numWords = 0;
  9. int count = 0;
  10. words = (char **) calloc(INITIAL_SIZE, sizeof(char *));
  11. int length[15];
  12. for(i = 0; i < 15; i++)
  13. {
  14. length[i] = 0;
  15. }
  16. FILE * f;
  17. f = stdin;
  18. c = getc(f);
  19. w = buf;
  20. while(c != EOF)
  21. {
  22. if(isalpha(c))
  23. {
  24. *w++ = c;
  25. count++;
  26. }else{
  27. if (buf == w)
  28. {
  29. c = getc(f);
  30. continue;
  31. }
  32. *w++ = 0;
  33. w = buf;
  34. numWords++;
  35. length[count]++;
  36. count = 0;
  37. }
  38. c = getc(f);
  39. }
  40. print(length);
  41. }
  42.  
  43. void print(int a[])
  44. {
  45. int i, j;
  46. for(i = 0; i < 15; i++)
  47. {
  48. printf("%d. ", i);
  49. for(j = 0; j < a[i]; j++)
  50. {
  51. printf("*");
  52. }
  53. printf("\n");
  54.  
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement