Advertisement
CosmicFox33

blya228

Dec 3rd, 2021
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. #include <locale.h>
  6. int main()
  7. {
  8. setlocale(LC_ALL,"Russian");
  9. system("chcp 1251");
  10. system("cls");
  11. char q[]={"йцукенгшщзхъфывапролджэячсмитьбюё"};
  12. FILE *fp, *fp1;
  13. int i,j,b,flag=0, colnew=0, col=0;
  14. char name[]="test1.txt";
  15. char name1[81];
  16. char str[81];
  17. if ((fp=fopen(name,"r"))==NULL)
  18. {
  19. printf("imposible to open file\n");
  20. getchar();
  21. return 0;
  22. }
  23. printf("enter the name of the new file with '.txt'\n");
  24. gets(name1);
  25. fp1=fopen(name1,"w");
  26. while (!feof(fp))
  27. {
  28. if(fgets(str,80,fp))
  29. {
  30. col++;
  31. i=0;
  32. j=0;
  33. b=strlen(str);
  34. //printf("%d",b);
  35. while (i<b)
  36. {
  37. if (strchr(q,str[i])==NULL && str[i]!='\n' && str[i]!='\0')
  38. {
  39. str[j]=str[i];
  40. j++;
  41. flag=1;
  42. }
  43. i++;
  44. }
  45. if(j!=0)
  46. {
  47. colnew++;
  48. for(i=j;i<b;i++)
  49. str[i]='\0';
  50. fputs(str, fp1);
  51. fputs("\n", fp1);
  52. puts(str);
  53. }
  54. }
  55. }
  56. if(colnew==col)
  57. {
  58. fprintf(fp1, "File has not changed\n");
  59. printf("File has not changed\n");
  60. }
  61. if(colnew==0)
  62. {
  63. fprintf(fp1, "All lines have been deleted\n");
  64. printf("All lines have been deleted\n");
  65. }
  66. fclose(fp);
  67. fclose(fp1);
  68. return 0;
  69. }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement