Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main()
- {
- system("chcp 1251");
- FILE *inputF, *outputF;
- char input[] = "C:\\Users\\admin\\Desktop\\Studlance500\\bin\\Debug\\input.txt";
- char output[] = "C:\\Users\\admin\\Desktop\\Studlance500\\bin\\Debug\\output.txt";
- char line[100];
- size_t line_len;
- int i;
- if ((inputF = fopen(input, "rb")) == NULL)
- {
- printf("Не удалось открыть файл");
- return 0;
- }
- if ((outputF = fopen(output, "wb")) == NULL)
- {
- printf("Не удалось открыть файл");
- return 0;
- }
- fgets(line, sizeof(line), inputF);
- printf("First Line: %s", line);
- line_len = strlen(line) - 1;
- printf("Input Length - %d\n\n", line_len);
- fputs(line, outputF);
- while(!feof(inputF)){
- char symbol;
- fscanf(inputF, "%c", &symbol);
- if(symbol == line[0]){
- char temp = symbol;
- int match = 1;
- for(i = 1; i < line_len - 1; i++){
- fscanf(inputF, "%c", &temp);
- if(temp != line[i]){
- match = 0;
- break;
- }
- }
- if(match == 1){
- fseek(inputF, -line_len + 2, SEEK_CUR);
- printf("%c", '@');
- fputc('@', outputF);
- }
- else{
- fseek(inputF, -i, SEEK_CUR);
- }
- }
- printf("%c", symbol);
- fputc(symbol, outputF);
- }
- fclose(inputF);
- fclose(outputF);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement