Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <stdlib.h>
- #define len 256 /*длина считываемой и записываемой строк*/
- typedef
- char str_20[20];
- typedef
- struct
- {
- str_20 w;
- int n;
- }rec;
- str_20 w;
- char s[len]; /*объявили S*/
- int check,k,i;
- char c, endword;
- void words(FILE *rfile)
- {
- int m=0;
- int check;
- char r[len];
- char dr[len];
- char p[len];
- check=fclose(rfile);
- rfile=("Helpfile.txt","r+");
- while (!feof(rfile))
- {
- fgets(r, len, rfile);
- if (strncpy(dr,r,strlen(w))==w) //если есть, добавляем номер как строку
- { /*преобразование позиции в строку*/
- strcat(r, " ");
- strcat(r, p);
- fseek(rfile, SEEK_SET+m, SEEK_SET);
- fputs(r, rfile);
- c=1;
- break; //и выходим
- }
- m++;
- }
- if (!c)
- { /*преобразование позиции в строку*/
- strcat(r, " ");
- strcat(r, p);
- fputs(r, rfile);
- }
- w[0]='\0';
- endword=0;
- }
- void main(void)
- {
- FILE *tfile; /*объявили tfile*/
- FILE *rfile=fopen("Helpfile.txt","w"); /*объявили rfile*/
- tfile=fopen("File.txt","r");
- if(tfile == NULL)
- {
- puts("Problems");
- }
- puts("Прошли))\n");
- while (!feof(tfile))
- {
- k++;
- fgets(s, len, tfile);
- for(i=1; i<strlen(s); i++)
- { /*заглавные буквы прописные буквы цифры (a>0x40 && a<0x5B)||(a>0x60 && a<0x7B)||(a>0x30 && a<0x39)*/
- if (isalnum(s[i]))
- c=1;
- if (c!=0)
- {
- strcat(w, s[i]);
- if ((s[i+1] == ' ') || ( i+1 > strlen(s)))
- endword= 1;
- }
- c=0;
- if (endword)
- words(rfile);
- c=0;
- }
- }
- check=fclose(rfile);
- rfile=("Helpfile.txt","r");
- while (!feof(tfile))
- {
- fgets(s, len, tfile);
- printf("%s\n", s);
- }
- fflush(stdin);
- check=fclose(rfile);
- check=remove("Helpfile.txt");
- }
Add Comment
Please, Sign In to add comment