int main(void) { FILE *fp, *fp2, *fp3; /*File pointers*/ char hard[7], soft[7], flat[7], round[7]; /*Input vowels*/ char plural[15][20]; /*Output plural nouns*/ char word[15][20]; /*Input nouns*/ bool control; /*Whether it is harmonies*/ int i; /*For loops*/ int size=0; /*Number of nouns*/ /*Open Vowels.txt if couldn't open print the screen warning message*/ fp=fopen(VOWELS, "r"); if(fp==NULL) printf("Vowels.txt counldn't open..."); /*Reads vowels from file*/ fgets(hard,7,fp); fgets(soft,7,fp); fgets(flat,7,fp); fgets(round,7,fp); fclose(fp); /*Open Nouns.txt if couldn't open print the screen warning message*/ fp2=fopen(NOUNS, "r"); if(fp2==NULL) printf("Nouns.txt counldn't open..."); /*Reads nouns from file*/ i=0; while(fscanf(fp, " %s", word[i])!=EOF) { size++; i++; } fclose(fp2); /*##########################Print the screen results##########################*/ printf("\n%10cMajor%4cMinor", ' ', ' '); for(i=0;i<size;i++) { printf("\n%-12s", word[i]); control=is_major_vh_word(word[i], hard, soft); if(control==1) printf("T%8c", ' '); else printf("F%8c", ' '); control=is_minor_vh_word(word[i], flat, round); if(control==1) printf("T"); else printf("F"); } printf("\n\n<<<<Plural of the nouns>>>>"); for(i=0;i<size;i++) { make_plural(word[i] , plural[i], hard, soft); printf("\n%s---%s", word[i],plural[i]); } printf("\n\n"); /*Open Plural.txt if couldn't open print the screen warning message*/ fp3=fopen(PLURAL, "w"); if(fp3==NULL) printf("Plural.txt counldn't open..."); /*Writes to file plural nouns*/ for(i=0;i<size;i++) { make_plural(word[i] , plural[i], hard, soft); fprintf(fp3,"%s\n",plural[i]); } return 0; }
int main() { char word[NUM_NAMES][LETTER],v_hard[3],v_soft[2],v_flat[3],v_round[2];/* defines the strings arrays*/ char plural_noun[NUM_NAMES],pl_noun[NUM_NAMES+3];/*defines the nouns arrays*/ char cell,a;/*defines the char*/ int i,k=0,row=0;/*defines the integers for loop*/ bool c, d;/*defines the bool values*/ FILE *inp;/*defines the vowels file*/ inp=fopen("Vowels.txt","r");/*open file*/ /*this loop for scan the vowels until EOF*/ while( fscanf(inp,"%c",&cell)!=EOF ) { /*this control change the array*/ if(cell=='\n') { row=0; a=cell; k++; } /*scan the hard letter array*/ else if(k==0) { v_hard[row]=cell; row++; } /*scan the soft letter array*/ else if(k==1) { v_soft[row]=cell; row++; } /*scan the flat letter array*/ else if(k==2) { v_flat[row]=cell; row++; } /*scan the round letter array*/ else if(k==3) { v_round[row]=cell; row++; } } fclose(inp);/*close file*/ FILE *inp2;/*define the nouns file*/ inp2=fopen("Nouns.txt","r");/*open the file*/ i=0; /*this loop scan the words array from the file*/ while(fscanf(inp,"%s",word[i])!=EOF) { i++; } fclose(inp2);/*close the file*/ printf("Reading the vowels..\n"); printf("Reading the nouns..\n"); printf("The maintaince harmonies\n"); printf(" MAJOR MINOR\n"); /*this loop doing control word for major and minor harmony rules*/ for(i=0;i<9;i++) { printf("%s ",word[i]); c=is_major_vh_word(word[i],v_hard,v_soft); if(c==TRUE) printf("T "); else printf("F "); d=is_minor_vh_word(word[i],v_flat,v_round); if(d==TRUE) printf("T\n"); else printf("F\n"); } printf("Writing the plurals of the nouns...\n"); FILE *outp;/*defines the plural nouns file*/ outp=fopen("Plural.txt","w");/*open the file*/ /*this loop for doing plural of the nouns*/ for(i=0;i<9;i++){ make_plural(word[i],plural_noun, v_hard, v_soft ); fprintf(outp,"%s\n",plural_noun); } fclose(outp);/*close the file*/ return 0; }