c - making a word search puzzle? -


i've made program allows choose size of grid , allows enter 20 words. have insert entered words horizontally original array using function. function must return value success , value failure enter word puzzle board. need getting started actual function should along function prototype. pseudocode helpful. i'm new programmer great. thank you

#include<stdio.h> #include<string.h>  void printmatrix(char matrix[][20],int); void inserthor(char matrix[][20],int);  int main(void) {     //declare variables     char matrix[20][20];     char words[20][100];      int x;     int a,b;     int i=0;     int n=0;      (a=0;a<20;a++)     {         (b=0;b<20;b++)         {             matrix[a][b] = '+';         }     }      while (x<10 || x>20)     {         printf("how large puzzle (between 10 , 20):\n");         scanf("%d",&x);     }      printmatrix(matrix,x);      //part 3      printf("enter 20 words hide in puzzle.\n");     printf("enter word 'done' after last word if entering less 20 words.\n");     (i = 0; < 20; i++)     {         printf("enter word %2d:\n", i+1);         if (scanf("%99s", words[i]) != 1 || strcmp(words[i], "done") == 0)             break;     }     n = i;     printf("%d words entered\n", n);     (i = 0; < n; i++)         printf("word %2d = [%s]\n", i+1, words[i]);     return 0; }  void printmatrix(char matrix[][20],int x) {     int i,j;     printf("empty puzzle:\n");      (i=0;i<x;i++)     {         (j=0;j<x;j++)         {             printf(" %c ", matrix[i][j]);         }         printf("\n");     } } 

your function prototype

void inserthor(char matrix[][20],int); 

lacks parameter word entered , value returned. use

char *inserthor(char matrix[][20], int order, char *word) {     int i, j, l = strlen(word);     (i = 0; < order; ++i)     (j = 0; j <= order-l; ++j)         if (matrix[i][j] == '+') return memcpy(&matrix[i][j], word, l);     return null; } 

which returns address of inserted word success , null failure.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -