return n;
}
+/* Output the clues to text file */
+void export_clues (Puzzle *p, const char *filename)
+{
+ FILE *outfile = fopen (filename, "w");
+ if (outfile == NULL)
+ {
+ fprintf (stderr, "%s\n", ERROR_WRITING_FILE);
+ exit (1);
+ }
+ /* first the across clues */
+ fprintf (outfile, "ACROSS CLUES\n");
+ for (int i = 0; i < p->grid_size; i ++)
+ {
+ for (int j = 0; j < p->grid_size; j ++)
+ {
+ if (p->start_across_word[i][j] != -1)
+ fprintf (outfile, "%d - %s\n", p->start_across_word[i][j],
+ p->clue_across[i][j]);
+ }
+ }
+ /* now the down clues */
+ fprintf (outfile, "DOWN CLUES\n");
+ for (int i = 0; i < p->grid_size; i ++)
+ {
+ for (int j = 0; j < p->grid_size; j ++)
+ {
+ if (p->start_down_word[i][j] != -1)
+ fprintf (outfile, "%d - %s\n", p->start_down_word[i][j],
+ p->clue_down[i][j]);
+ }
+ }
+ fclose (outfile);
+}
+
/* Output the grid to image - if answerkey is true export filled grid */
void export_grid_image (Puzzle *p, const char *filename, bool answerkey)
{
}
/* function to check if a word is valid or not */
-bool is_valid_word (const char *word)
+char* is_valid_word (char *word)
{
- for (int i = 0; i < strlen (word); i ++)
+ if (word == NULL || strlen(word) == 0)
+ return NULL;
+ for (int i = 0; i < strlen (word) - 1; i ++)
if (! isalpha (word[i]))
- return false;
+ return NULL;
- return true;
+ return strtok (word, "\n");
}
printf ("\u2550");
printf ("\u2557");
reset_color (); printf ("\n");
+ printf ("\u2551");
set_color (fg, bg, BOLD);
- printf ("\u2551%-*s\u2551", padding, title);
+ printf ("%-*s", padding, title);
+ reset_color ();
+ set_color (fg, bg, NORMAL);
+ printf ("\u2551");
reset_color (); printf ("\n");
set_color (fg, bg, NORMAL);
printf ("\u2560");