Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main()
  6. {
  7. system("chcp 1251");
  8.  
  9. FILE *inputF, *outputF;
  10. char input[] = "C:\\Users\\admin\\Desktop\\Studlance500\\bin\\Debug\\input.txt";
  11. char output[] = "C:\\Users\\admin\\Desktop\\Studlance500\\bin\\Debug\\output.txt";
  12. char line[100];
  13. size_t line_len;
  14. int i;
  15.  
  16. if ((inputF = fopen(input, "rb")) == NULL)
  17. {
  18. printf("Не удалось открыть файл");
  19. return 0;
  20. }
  21. if ((outputF = fopen(output, "wb")) == NULL)
  22. {
  23. printf("Не удалось открыть файл");
  24. return 0;
  25. }
  26.  
  27. fgets(line, sizeof(line), inputF);
  28. printf("First Line: %s", line);
  29. line_len = strlen(line) - 1;
  30.  
  31. printf("Input Length - %d\n\n", line_len);
  32.  
  33. fputs(line, outputF);
  34.  
  35. while(!feof(inputF)){
  36. char symbol;
  37. fscanf(inputF, "%c", &symbol);
  38.  
  39. if(symbol == line[0]){
  40. char temp = symbol;
  41. int match = 1;
  42. for(i = 1; i < line_len - 1; i++){
  43. fscanf(inputF, "%c", &temp);
  44. if(temp != line[i]){
  45. match = 0;
  46. break;
  47. }
  48. }
  49.  
  50. if(match == 1){
  51. fseek(inputF, -line_len + 2, SEEK_CUR);
  52. printf("%c", '@');
  53. fputc('@', outputF);
  54. }
  55. else{
  56. fseek(inputF, -i, SEEK_CUR);
  57. }
  58.  
  59. }
  60. printf("%c", symbol);
  61. fputc(symbol, outputF);
  62. }
  63.  
  64. fclose(inputF);
  65.  
  66. fclose(outputF);
  67. return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement