Code:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <string.h>
int main (void)
{
char a[21];
char b[21];
char c[99];
int d;
FILE *syns;
FILE *thes;
FILE *alp;
syns = fopen ( "syns", "r");
thes = fopen ( "thes", "r");
alp = fopen ( "alp", "w");
fseek( syns, 0L, SEEK_SET );
while(1==fscanf(syns,"%s",a)) /*While there are words, take a word from the list*/
{fseek( thes, 0L, SEEK_SET);/*go to beginning of thesaurus*/
fprintf(alp,"'%s'",a);
while(1==fscanf(thes,"%s",b)) /*While there are words in thesaurus, take one and...*/
{
if (strcmp(a,b)==0) /*...Compare it to the word from the list, if they are the same*/
{
fprintf(alp,"%s- ",a);/*Print the word*/
for(d=0;d<=15;d++)/*Pick amount of synonyms*/
{
fscanf(thes,"%s",c); /*take current word*/
fprintf(alp,"%s, ",c);/*print it*/
}
fprintf(alp,"\n");/*Goto a newline when finished*/
}
}
}
return (0);
}
outputs
Code:
'abortive'abortive- barren, bootless, failed, failing, fruitless, futile, gainless, immature, ineffective, ineffectual, inefficacious, lame, manque, miscarried, miscarrying, nonremunerative,
t- true_to_form, true_to_type, typal, typic, typical, unblamable, unexceptionable, usual, virtuous, warning, well-deserving, worthy, exemplification, allegorization, alphabet, art,
'bruit't- true_to_form, true_to_type, typal, typic, typical, unblamable, unexceptionable, usual, virtuous, warning, well-deserving, worthy, exemplification, allegorization, alphabet, art,
'contumelious'contumelious- corrupt, crooked, cruel, cursing, damnatory, defamatory, degrading, denunciatory, deprecative, deprecatory, depreciative, depreciatory, derisive, derisory, derogative, derogatory,
t- true_to_form, true_to_type, typal, typic, typical, unblamable, unexceptionable, usual, virtuous, warning, well-deserving, worthy, exemplification, allegorization, alphabet, art,
Thus, the output is correct, but in the middle there are spasms of the wrong word, as well as the word not getting synonyms in some cases. Green= char a before second while loop. yellow = erroneous output.