Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- 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( mas[i] >= 'a' && mas[i] <= 'p')
- outputMas[s++] = mas[i];
- }
- outputMas[s] = '\0';
- printf("%s", outputMas);
- fprintf(output_file, "%s", outputMas);
- }
- printf("/n");
- }
- int main(int argc, const char * argv[]) {
- FILE* input_file;
- FILE* output_file = NULL;
- char fileName[20];
- int n = 0;
- do{
- printf("Введите имя файла: ");
- scanf("%s", fileName);
- n = strlen(fileName);
- }
- while(strstr(fileName,".txt") == NULL);
- input_file = fopen(fileName, "r");
- if(input_file == NULL){
- printf("Файл не может быть открыт или создан\n");
- }
- else printf("Файл успешно открыт\n");
- fileName[n - 3] = 'd';
- fileName[n - 2] = 'a';
- fileName[n - 1] = 't';
- writeMat(input_file, output_file);
- fclose(input_file);
- fclose(output_file);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement