include stdio include string include stdlib include locale int main in

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <locale.h>
int main()
{
int size, i, j=1, x1, x2;
char *p, word[]="for", search1[]="printf", *mb1, search2[]="scanf", *mb2;
size_t word_len = strlen(word);
FILE *text;
setlocale(LC_ALL,"");
if ((text=fopen("main1.c","rb"))==NULL)
{
perror("");
return EXIT_FAILURE;
}
else
{
fseek(text, 0L, SEEK_END);
size = ftell(text);
fseek(text, 0L, SEEK_SET);
char *buffer = (char *)malloc(size+1);
fread((void *)buffer, 1, size, text);
//-----------------------------------
while (p=strstr(buffer, word))
memmove(p, p+word_len, strlen(p+word_len)+1);
printf(" %s\n", buffer);
//-----------------------------------
for(i=0; i<size-30; i++)
{
if(buffer[i]=='\n')
{
j++;
for(x1=0; x1<sizeof(search1);x1++)
mb1=buffer[i];
for(x2=0; x2<sizeof(search2);x2++)
mb2=buffer[i];
while(strcmp(mb1,search1) || strcmp(mb2,search2))
printf("%i\n",j);
}
}
}
return 0;
}