Hi guys, im new to these forums and would like some help with two problems im having in my program to make crossword
The crossword requires me to read 5 inputs in one line.
word row column direction clue

Problem 1- input
I wish to getchar the first word

while((answerInput[count][i++]=getchar())!=' ' && i<SIZE);


                    answerInput[count][i]='\0';




                    /*TO SCAN FOR THE WORD, HOW TO TERMINATE AT SPACE..THIS INCLUDES SPACE*/

Problem 2 - equating arrays
Im having trouble storing the word 2d array into the board 2d array

   int i;
   int j;

   int rowInputInt = (int)rowInput[count];
     if (direction[count]=='d')
     { 
          j=columnInput[count];

          for(i=rowInputInt;i<rowInputInt+strlen(answerInput[count]);i++)
         {  
               board[i][j]=answerInput[count][i];
         }
     }

     /*This not storing into array...so when i print the board 
       nothing happens at moment*/

Can you guys please tell me how to fix this. Im pretty new to C.

Recommended Answers

All 5 Replies

K i think i fixed problem 2
replacing the loop to be

if (direction[count]=='d')
     { 
          j=columnInput[count];
          for(i=rowInputInt,k=0;i<rowInputInt+strlen(answerInput[count])&&k<strlen(answerInput[count]); k++,i++)
         {  
               board[i][j]=answerInput[count][k];
         }
     }

//it displays on board :D. But still white space placed on board from first issue

K i fixed problem 1 replacing with --i

Can someone help me fix this. I need to exit if they type only '.' in the total field. How do i exit if they type this

              /*if (getchar()!='.')
              {
              answerInput[count][0]=m;                              
              */  
               while((answerInput[count][i++]=getchar())!=' ' && i<SIZE)
               {
                    if(answerInput[count][i]=='.')
                    {
                         printf("ERROR");
                    }     
               }          

                    answerInput[count][--i]='\0';

//Its not exiting
if(answerInput[count][i]=='.')
{
    printf("ERROR");
    break;
} 

or something like that is possible bot i didnt tested just a sketch

//read 
char c = getchar();
while(c!='.' && i<SIZE)
{
    answerInput[count][i++] = c;
c = getchar();// get next char then
}
answerInput[count][--i]='\0';

Thanks, altered a little but concept works well

int i=0;             
          char c=getchar();

          if(c=='.')                              
          {
               printf("ERROR");

          }     
          while((c!=' ' && i<SIZE))
          {                                            //ANSWERINPUT
               answerInput[1][i++]=c;
               c=getchar();
          }                    
          answerInput[1][i]='\0';                 
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.