Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <ctype.h>
- #define ASCENDING 1
- #define DESCENDING -1
- #define INITIAL_SIZE 10
- void print(int[]);
- int main(int argc, char * argv[])
- {
- char *w;
- char c;
- char **words;
- char buf[64];
- int i;
- int numWords = 0;
- int count = 0;
- words = (char **) calloc(INITIAL_SIZE, sizeof(char *));
- int length[15];
- for(i = 0; i < 15; i++)
- {
- length[i] = 0;
- }
- FILE * f;
- f = stdin;
- c = getc(f);
- w = buf;
- while(c != EOF)
- {
- if(isalpha(c))
- {
- *w++ = c;
- count++;
- }else{
- if (buf == w)
- {
- c = getc(f);
- continue;
- }
- *w++ = 0;
- w = buf;
- numWords++;
- length[count]++;
- count = 0;
- }
- c = getc(f);
- }
- print(length);
- }
- void print(int a[])
- {
- int i, j;
- for(i = 0; i < 15; i++)
- {
- printf("%d. ", i);
- for(j = 0; j < a[i]; j++)
- {
- printf("*");
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement