Zennoma

Не робит

Dec 18th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <conio.h>
  4. #include <stdlib.h>
  5. int main()
  6. {
  7. int k = 0;
  8. FILE* F;
  9. char str[100];
  10. char FILEName1[20];
  11. char FILEName2[20];
  12. puts("Enter first file name");
  13. gets_s(FILEName1, 20);
  14. fopen_s(&F, FILEName1, "w+t");
  15. puts("Enter strings");
  16. int b = 0;
  17. while (gets_s(str, 100), strlen(str) != 0)
  18. {
  19. fputs(str,F);
  20. fputs("\n", F);
  21. }
  22. rewind(F);
  23. puts("FileF");
  24. while (fgets(str, 100, F) > 0)
  25. {
  26. puts(str);
  27. }
  28. rewind(F);
  29. FILE* G;
  30. puts("Enter second file name");
  31. gets_s(FILEName2, 20);
  32. fopen_s(&G, FILEName2, "w+t");
  33. fseek(F, 0, SEEK_SET);
  34. fgets(str, 100, F);
  35. b = atoi(str);
  36. fseek(F, 0, SEEK_END);
  37. fgets(str, 100, F);
  38. b += atoi(str);
  39. sprintf_s(str, "%d", b);
  40. fputs(str, G);
  41. fclose(F); fclose(G);
  42. puts("Elements of file G");
  43. fopen_s(&G, FILEName2, "r+t");
  44. int num = 1;
  45. while (fgets(str, 100, G) > 0)
  46. {
  47. printf_s("string order %d ", num);
  48. puts(str);
  49. }
  50. fclose(G);
  51. return(0);
  52. }
Add Comment
Please, Sign In to add comment