#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
void otkritie(char predl[80])
{
FILE *prdlj;
prdlj = fopen("stu.bin","rb");
while (!(feof(prdlj)))
fscanf(prdlj,"%s", predl);
printf("%s\n", predl);
fclose(prdlj);
}
int delenie(char *predl,char delpredl[][20])
{
int i=0;
char *p;
char *v = " ";
p = strtok(predl,v);
while (p)
{
i++;
strcpy(delpredl[i],p);
p= strtok(NULL,v);
}
return i;
}
void sravn(int g1,int g2,char delpredl [][20], char predlpred[][20])
{
int i,j,k,l;
FILE *outpl;
outpl = fopen("ut1.bin","wb");
l=0;
k=0;
for (i=1;i<=g1;i++)
{
l=0;
for (j=1;j<=g2;j++)
{
k=strcmp(delpredl[i],predlpred[j]);
if (k!=0)
l++;
k=0;
}
if (l==g2)
{
fprintf(outpl,"%s",delpredl[i]);
fprintf(outpl,"%c",' ');
}
}
fclose(outpl);
}
int main()
{
char predl[80];
char delpredl[20][20];
char predlpred[20][20];
char pred[]="v bez do iz k na ot";
int g1,g2;
otkritie(predl);
g1=delenie(predl,delpredl);
g2=delenie(pred,predlpred);
printf("%d\n",g1);
printf("%d\n",g2);
sravn(g1,g2,delpredl,predlpred);
printf("\n");
return 0;
}