Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- int main(void) {
- FILE* fin;
- FILE* fout;
- char d[4001];
- char word[4001];
- int sym, i = 0, lend = 0, lenw = 0;
- if ((fin = fopen("input.txt", "rw")) == NULL)
- {
- printf("cannot open input file!\n");
- return -1;
- }
- if ((fout = fopen("output.txt", "rw")) == NULL)
- {
- printf("cannot open output file!\n");
- fclose(fin);
- return -1;
- }
- while ((sym = fgetc(fin)) != EOF && !isspace(sym)) //считали W
- {
- d[i] = sym;
- //putchar(sym);
- i++;
- lend++;
- }
- i = 0;
- while ((sym = fgetc(fin)) != EOF)
- {
- if (!isspace(sym))
- {
- word[i] = sym;
- //putchar(sym);
- lenw++;
- i++;
- }
- else if (lenw < lend)
- {
- for (int p = 0; p < lenw; p++)
- {
- fputc(word[p], fout);
- }
- fprintf(fout, " ");
- lenw = 0;
- i = 0;
- }
- else if (strstr(word, d) == NULL)
- {
- //printf("%s \n", word);
- //printf("%d \n", lenw);
- for (int p = 0; p < lenw; p++)
- {
- fputc(word[p], fout);
- }
- fprintf(fout, " ");
- lenw = 0;
- i = 0;
- }
- else
- {
- //printf(" ");
- lenw = 0;
- i = 0;
- }
- }
- fclose(fin);
- fclose(fout);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement