Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(int argc, char *argv[]){
  6.  
  7. char puzzle[101];
  8. int size;
  9. FILE *fp = fopen(argv[2], "r");
  10. if(fp == NULL){
  11. printf("Error, file does not exist\n");
  12. return 1;
  13. }
  14. fscanf(fp, "%s", puzzle);
  15. sscanf(argv[1], "%d", &size);
  16.  
  17. char word;
  18. int **array, a;
  19.  
  20. array = malloc(sizeof(int*) * size);
  21.  
  22. for(a=0; a<size; a++){
  23. array[a] = malloc(sizeof(int) * size);
  24.  
  25. while(strcmp(word, "zzz") != 0){
  26.  
  27. buildPuzzle(array, size, size);
  28.  
  29. printf("The word puzzle is:\n%s\n", word);
  30.  
  31. printf("Enter a word to find in the puzzle: ");
  32.  
  33. }
  34.  
  35. fclose(fp);
  36.  
  37. return 0;
  38. }
  39.  
  40. void buildPuzzle(int **data, int row, int col){
  41.  
  42. int a, b;
  43. for(a=0; a<row; a++){
  44. for(b=0; b<col; b++){
  45. data[a][b] = size;
  46. }
  47. }
  48. return;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement