Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- char *readFile(char *fileName) {
- FILE *file = fopen(fileName, "r");
- char *code;
- size_t n = 0;
- int c;
- if (file == NULL) return NULL;
- fseek(file, 0, SEEK_END);
- long f_size = ftell(file);
- fseek(file, 0, SEEK_SET);
- code = malloc(f_size);
- while ((c = fgetc(file)) != EOF) {
- code[n++] = (char)c;
- }
- code[n] = '\0';
- return code;
- }
- int main()
- {
- FILE *output = fopen("c.txt", "w");
- if(!output)
- exit(1);
- char *input = readFile("a.txt");
- char *input_b = readFile("b.txt");
- if(!input)
- exit(2);
- if(!input_b)
- exit(3);
- for(int i = 0; i < strlen(input); i++)
- {
- char in = input[i];
- if(in == '<' || in == '>' || in == '=')
- {
- fputc(in, output);
- fputc(' ', output);
- }
- }
- for(int i = 0; i < strlen(input_b); i++)
- {
- char in = input_b[i];
- if(islower(in))
- {
- fputc(in, output);
- fputc(' ', output);
- }
- }
- fclose(output);
- printf("Done!\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement