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 wordef wordslist;
- struct wordef {
- 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, k=0;
- wordslist words[999];
- 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]='.';
- }
- }
- int getout = 1;
- getchar();
- int b = 0;
- int r = 0;
- int breaker = 1;
- while(breaker) {
- while((c = getchar()) != EOF) {
- if (c == '\n') {
- if (r == 0) {
- breaker = 0;
- }
- break;
- } else {words[b].letters[r] = c;r++; }
- }
- r = 0;
- b++;
- }
- // printf("%d",b-1);
- //print the grid
- // printgrid(grid[MAXGRIDCOLS][MAXGRIDROWS], numCols, numRows,
- // *words[MAXNUMWORDS][MAXWORDLEN]);
- for(i=0; i<b-1; i++){
- printf("%s\n", words[i].letters);
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement