/*this program has been condensed from over 2400 word combinations down to 27
It is for arranging the meanings of words in the order the words were written. Many words have several meanings (descriptions).
*/

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>
#define TRUE 1
#define FALSE !TRUE
#define MAX_LINE_BUFFER 128
char buffer[MAX_LINE_BUFFER];
char stay_open,c,menu,ans;
char select_1;

char str_a[20],str_aa[20],str_aaa[20];
char str_b[20],str_bb[20],str_bbb[20];
char str_c[20],str_cc[20],str_ccc[20];

void main (void)
{
  stay_open=TRUE;
  while (stay_open)
  {
    do
    {
      printf("\n Menu for selecting combinations of words and meanings.");
      printf("\n Numbers under 'word' represents number of meanings.");
      printf("\n Example: If 1st word has 3 meanings and 2nd word has");
      printf("\n 3 meanings you would Enter Selection 3.");
      printf("\n	Select	1st	2nd	3rd");
      printf("\n		word	word	word\n");
      printf("\n	3.	3	3");
      printf("\n	4.	3	3	3");				
      			
      printf("\n Enter your selection ");
      fgets (buffer, MAX_LINE_BUFFER, stdin);
      select_1 = atoi (buffer);
      if ( (select_1 <= 2 ) || (select_1 >= 5) )
      printf("\nOops, try again!\n");
    }
    while ( (select_1 <= 2) || (select_1 >= 5) );

    switch (select_1)
    {
      case 3:
      printf("\nEnter 1st meaning for first word   ");
      scanf ("%s",str_a);
      printf("Enter 2nd meaning for first word   ");
      scanf ("%s",str_aa);
      printf("Enter 3rd meaning for first word   ");
      scanf ("%s",str_aaa);
      printf("\nEnter 1st meaning for second word   ");
      scanf ("%s",str_b);
      printf("Enter 2nd meaning for second word   ");
      scanf ("%s",str_bb);
      printf("Enter 3rd meaning for second word   ");
      scanf ("%s",str_bbb);

      printf("\n%s %s   %s %s   %s %s\n",
      str_a,str_b,str_a,str_bb,str_a,str_bbb);
      printf("\nPress any key continue\n");
      getch();
      printf("\n%s %s   %s %s   %s %s\n",
      str_aa,str_b,str_aa,str_bb,str_aa,str_bbb);
      printf("\nPress any key continue\n");
      getch();
      printf("\n%s %s   %s %s   %s %s\n",
      str_aaa,str_b,str_aaa,str_bb,str_aaa,str_bbb);
      break;

      default:
      printf("\nThe only working option is 3.");
      printf("\nPress any key continue");
      getch();
      break;
    }
      printf("\nDo again? N for NO,any key for yes");
      c=toupper(getch());
      if(c=='N')
      {
        stay_open=!TRUE;
        printf("\n\nAdios");
      }
    }   
}

______________________________________________________________________
I would like to rewrite it something like this:

char a,aa,aaa,b,bb,bbb,c,cc,ccc
char wrd_1[]={40,40,40};
char wrd_2[]={40,40,40};
char wrd_3[]={40,40,40};

a = wrd_1[0],aa=wrd_1[1],aaa=wrd_1[2];//same for wrd_2 and wrd_3

each description wants to have its own element.

printf("\nEnter up to 3 descriptions for the 1sr word. ");//provision needed here for fewer //than 3 meanings
//this next block has me totally cornfused
fgets(wrd_1[0][1][2],MAX_LINE,stdin);??how to get into all the individual elements for each word??

If I could get some help on the the bottom section I would like to figure out the rest on my own......maybe....
I would really appreciate a snippet for this part as I have read every tutorial in the world and still cannot get this to compile....or if it does compile I get a crash and protection fault or some such thing.....
Thanks and hopefully I haven't violated any of your rules.....
FL

Comments
Congratulations on using code tags with your first post.

Consider using a struct, like

typedef struct {
    char word[20];
    int  numDefs;
    char defs[10][30];
} definitions;

Then you could have something like definitions dictionary[100]; The raw input code would be something like

for ( w = 0 ; w < 100 ; w++ ) {
  // read a word into dictionary[w].word
  for ( d = 0 ; d < 10 ; d++ ) {
    // read a description into dictionary[w].defs[d]
    // increment dictionary[w].numDefs
    // provide a means of early escape from the loop, say a blank line
  }
}

Though you'd probably want to make it so the user only has to add one word / definition at once, and offer editing features.

This article has been dead for over six months. Start a new discussion instead.