Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main (void) {
  4. FILE *in;
  5. FILE *out;
  6. char name[128];
  7. unsigned char c, d;
  8. int n = 0, flag = 0;
  9. printf ("Введите имя файла\n");
  10. scanf ("%s", name);
  11. in = fopen (name, "r");
  12. out = fopen ("decode.bmp", "w");
  13. if ((out == NULL) || (in == NULL)) {
  14. printf ("Файл не создан\n");
  15. return 0;
  16. }
  17. while (fscanf (in, "%c", &c) != EOF) {
  18. fscanf (in, "%c", &d);
  19. for (int i = 0; i < (int) c; i++) {
  20. fprintf (out, "%c", d);
  21. }
  22. /*if (n == 254) {
  23. fprintf (out, "%c%c", (unsigned char) (n + 1), d);
  24. n = -1;
  25. }
  26. if ((c == d) && (flag != 0)) {
  27. n++;
  28. } else {
  29. if (flag == 0) {
  30. flag++;
  31. d = c;
  32. } else {
  33. fprintf (out, "%c%c", (unsigned char) (n + 1), d);
  34. d = c;
  35. n = 0;
  36. }
  37. }*/
  38. }
  39. //fprintf (out, "%c%c", (unsigned char) (n + 1), d);
  40. fclose (in);
  41. fclose (out);
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement