Advertisement
boyan16-z

The most distant alphabetically (files)

Mar 21st, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. int main() {
  6. FILE *s1, *s2;
  7. int symbol = 0, max = 0;
  8.  
  9. s1 = fopen("bit.txt", "r");
  10. s2 = fopen("bit2.txt", "w");
  11.  
  12. if (!s1)
  13. printf("Error open bit.txt\n");
  14. else
  15. {
  16. do
  17. {
  18. symbol = fgetc(s1);
  19. if (symbol >= 'a' && symbol <= 'z') {
  20. if (max == 0) max = symbol;
  21. if (max < symbol) max = symbol;
  22. }
  23. } while (symbol != EOF);
  24. fprintf(s2, "%c", (char)(max));
  25. }
  26.  
  27. fclose(s1);
  28. fclose(s2);
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement