Hi I'm making a crossword program which takes an input and prints it out onto a crossword board. The input is in the following format:
Puzzle-Word Row-Letter Column-Number Direction Clue
I can separate this input into its components. However I am having trouble taking the puzzle word and putting into the crossword grid. Is it possible for someone to give me some guidance to a possible solution for this?
Your help is much appreciated.
Here is the code I have written so far:
Code:
#include <stdio.h>
#define MAX_SIZE 12
#define DOT '.'
#define MAX_PUZZLE 10
#define CLUE_LENGTH 25
void printClues ();
void printBoard ();
int main(int argc, char *argv[]) {
printf("Enter new clue (type . if finished): ");
printClues ();
printBoard (puzzleWord);
return 0;
}
void printClues () {
char puzzleWord[MAX_PUZZLE];
char rowLetter;
int columnNum;
char direction;
char clue[CLUE_LENGTH];
//separates the input into its components
scanf("%s %c %d %c", puzzleWord, &rowLetter, &columnNum, &direction);
fgets(clue, CLUE_LENGTH, stdin);
//prints the separate components of the input to check for successful separation
printf("Puzzle-word: %s\n", puzzleWord);
printf("Row Letter: %c\n", rowLetter);
printf("Column Number: %d\n", columnNum);
if (direction == 'a'){
printf("Direction: ACROSS\n");
} else if (direction == 'd') {
printf("Direction: DOWN\n");
}
printf("Clue:%s", clue);
}
void printBoard (char board[MAX_SIZE][MAX_SIZE]) {
int i, j;
char c = 'a';
//INTIALISES THE EMPTY CROSSWORD GRIDE
for (i=0; i<MAX_SIZE; i++) {
for (j=0; j<MAX_SIZE; j++) {
board[i][j] = DOT;
}
}
//PRINTS THE BOARD
printf(" 0 1 2 3 4 5 6 7 8 91011\n");
for (i=0; i<MAX_SIZE; i++) {
printf("%c", c++);
for (j=0; j<MAX_SIZE; j++) {
printf(" %c", board[i][j]);
}
printf("\n");
}
printf("\n");
}