Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <stdlib.h>
  4.  
  5. int main()
  6. {
  7. FILE *f;
  8. char filename[256];
  9. int c; int chars = 0; int lines = 0; int letters = 0; int digits = 0; int uppers = 0; int lowers = 0 ; int spaces = 0; int puncts = 0;
  10. printf("Введите имя файла \n");
  11. scanf("%s", filename);
  12. f=fopen(filename,"r");
  13. if (!f)
  14. {
  15. printf("Файл не найден \n");
  16. return 0;
  17. }
  18. while((c=fgetc(f)) !=EOF)
  19. {
  20. chars++;
  21. if(c == '\n') lines++;
  22. if(isalpha(c)) letters++;
  23. if(isdigit(c)) digits++;
  24. if(isspace(c)) spaces++;
  25. if(isupper(c))uppers++;
  26. if(islower(c)) lowers++;
  27. if(ispunct(c)) puncts++;
  28. }
  29. printf("%d", letters);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement