Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #define MAXWORDLEN 200
- #define MAXNUMWORDS 200
- #define MAXGRIDCOLS 1000
- #define MAXGRIDROWS 1000
- #define TRUE 1
- #define FALSE 2
- typedef struct words Words;
- struct words{
- int x;
- int y;
- char letters[MAXWORDLEN];
- int used;
- };
- //extern void printgrid(char grid, int numCols, int numRows,
- // char *words[MAXNUMWORDS][MAXWORDLEN]);
- int main(void){
- int numCols;
- int numRows;
- int numWords=0;
- int i=0, j=0;
- char grid[MAXGRIDCOLS][MAXGRIDROWS];
- char c;
- //prompt user for game parameters
- printf("Enter number of rows and columns followed by a list of words: ");
- //get the number of rows and columns from input
- if(scanf("%d%d", &numRows, &numCols)==2);
- //initialise grid
- for(i=0; i<numCols; i++){
- for(j=0; j<numRows; j++){
- grid[i][j]='.';
- }
- }
- //get the words from input
- int breaker=1;
- while(breaker){
- while((c=getchar())!=EOF) {
- if (c=='\n'){
- if (j==0) {
- breaker=0;
- }
- break;
- }else{
- Words[i].letters[j]=c;
- j++;
- }
- }
- j=0;
- i++;
- numWords++
- }
- //print the grid
- // printgrid(grid[MAXGRIDCOLS][MAXGRIDROWS], numCols, numRows,
- // *words[MAXNUMWORDS][MAXWORDLEN]);
- for(i=0; i<numWords; i++){
- printf("%s", words[i].letters);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement