Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #define MAX_PHRASE_LEN 100
- char source_phrase[MAX_PHRASE_LEN];
- int source_phrase_len;
- int words_in_phrase = 1;
- int symbols_in_file = 0;
- void scan_phrase(FILE* fin)
- {
- fgets(source_phrase, MAX_PHRASE_LEN, fin);
- source_phrase[strlen(source_phrase) - 2] = 0;
- source_phrase_len = strlen(source_phrase);
- for (int i = 0; i < source_phrase_len; ++i) {
- if (source_phrase[i] == ' ' && source_phrase[i] == '\t') {
- ++words_in_phrase;
- }
- }
- }
- int main()
- {
- FILE* fin, * fout;
- fopen_s(&fin, "input.txt", "rb");
- fopen_s(&fout, "output.txt", "w");
- if (fin == NULL || fout == NULL) {
- return -1;
- }
- scan_phrase(fin);
- char word[MAX_PHRASE_LEN];
- char phrase[MAX_PHRASE_LEN];
- memset(word, 0, MAX_PHRASE_LEN);
- memset(phrase, 0, MAX_PHRASE_LEN);
- while (1) {
- for (int i = 0; i < words_in_phrase; ++i) {
- fscanf_s(fin, "%s", word);
- strcat_s(phrase, strlen(word), word);
- }
- }
- fclose(fin);
- fclose(fout);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement