Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include"pch.h"
- #include <stdio.h>
- #include <locale.h>
- #include <cstdlib>
- #include <string.h>
- void trans(char* name, FILE *file_input) {
- FILE *file_output;
- char stroka[579];
- fopen_s(&file_output, name, "w");
- fgets(stroka, 548, file_input);
- int i = 0;
- do {
- if (((stroka[i + 1] >= '0') && (stroka[i + 1] <= '9')) && ((stroka[i] >= '0') && (stroka[i] <= '9'))) {
- int a = (int)stroka[i];
- int a1 = (int)stroka[i + 1];
- int b = '0';
- int p = (a - b)*(a1 - b);
- fprintf_s(file_output, "%i", p);
- }
- else { fprintf_s(file_output, "%c", stroka[i]); }
- i++;
- } while (stroka[i] != '\0');
- fclose(file_output);
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- FILE * myfile;
- char input_name[20];
- printf("Введите имя файла: ");
- gets_s(input_name);
- unsigned long lon = 0;
- do
- {
- printf("Введите имя файла с расшираением <<.txt>>: ");
- gets_s(input_name);
- lon = strlen(input_name);
- }
- while (strstr(input_name, ".txt") == NULL);
- fopen_s(&myfile, input_name, "r");
- if (input_name == NULL)
- {
- printf("Файл не может быть открыт\n");
- }
- else
- printf("Файл успешно открыт\n");
- input_name[lon - 3] = 'd';
- input_name[lon - 2] = 'a';
- input_name[lon - 1] = 't';
- printf("Создан файл: %s\n", input_name);
- trans(input_name, myfile);
- fclose(myfile);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement