Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <stdio.h>
- #include <string.h>
- #include <locale.h>
- #include <cstdlib>
- int condition(char symbol){
- return symbol >= 'а' && symbol < 'р' || symbol == 'ё';
- }
- void writeMat(FILE* input_file, FILE* output_file){
- char mas[80] = "";
- char outputMas[80];
- //mas[0] = '\0';
- while (!feof(input_file)){
- int s = 0;
- fgets(mas, 80, input_file);
- for (int i = 0; mas[i] != '\0'; i++){
- if (!condition(mas[i]))
- outputMas[s++] = mas[i];
- }
- outputMas[s] = '\0';
- printf("%s", outputMas);
- fprintf_s(output_file, outputMas);
- }
- printf("/n");
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- setlocale(LC_ALL, "Russian");
- FILE* input_file = NULL;
- FILE* output_file = NULL;
- char fileName[20];
- unsigned long n = 0;
- do{
- printf("Введите имя файла: ");
- gets_s(fileName);
- n = strlen(fileName);
- } while (strstr(fileName, ".txt") == NULL);
- fopen_s(&input_file, fileName, "r");
- if (input_file == NULL){
- printf("Файл не может быть открыт или создан\n");
- }
- else printf("Файл успешно открыт\n");
- fileName[n - 3] = 'd';
- fileName[n - 2] = 'a';
- fileName[n - 1] = 't';
- printf("%s\n", fileName);
- fopen_s(&output_file, fileName, "w");
- writeMat(input_file, output_file);
- fclose(input_file);
- fclose(output_file);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement