fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct MQnode {
  5. CELL **ppCE;
  6. int iRows, iCols, iGoals, iStarts;
  7. }MAZE;
  8.  
  9. typedef struct CEnode {
  10. char cglyph;
  11.  
  12. }CELL;
  13.  
  14. MAZE *
  15. ReadMaze(FILE *fpIn)
  16. {
  17. register int j, k, c;
  18. register MAZE *pMQRet;
  19.  
  20. if ((MAZE *)0 == pMQRet = malloc(sizeof(MAZE)*1)) {
  21. if (2 != fscanf(fpIn, " %d,%d\n", &pMQRet->iRows, &pMQRet->iCols)) {
  22. EXIT_FAILURE;
  23. }
  24.  
  25. if (2 > pMQRet->iRows || 2 > pMQRet->iCols) {
  26. EXIT_FAILURE;
  27. }
  28.  
  29. if ((CELL *)0 == (pMQRet->ppCE = malloc(sizeof(CELL *)*iRows))) {
  30. EXIT_FAILURE;
  31. }
  32. //intialize goals and starts
  33.  
  34. for (j=0; j<iRows;++j){
  35. if ((CELL*)0 == pMQRet->ppCE[j] = malloc((pMQRet->iCols+1)* sizeof(CELL))){
  36. EXIT_FAILURE;
  37. }
  38. for (k=0; k<pMQRet->iCols+1;++k){
  39. if (EOF ==(c = fgetc(fpIn))){
  40. EXIT_FAILURE;
  41. }
  42.  
  43. }
  44. }ppCE[j][k] = c;
  45. }
  46. }return pMQRet;
  47.  
  48.  
  49. void
  50. PrintMaze(FILE *fpout, MAZE *pMQThis)
  51. {
  52. register int j,k,l;
  53. register CELL *pCE;
  54. if ((MAZE *)0 == pMQThis){
  55. exit(0);
  56. }
  57. for (l=0;l<pMQThis->iCols+2;++1)
  58. fputc('-',fpout);
  59. for (j=0;j<pMQThis->iRows;++j){
  60. pCE = pMQThis->ppCE[j];
  61. fputc('|',fpout);
  62. for (k=0; k<pMQThis->iCols;++k)
  63. fputc(pCE[k], cglyph,fpout);
  64. }
  65. fputc('|',fpout);
  66. fputc('\n',fpout);
  67. }
  68. fputc('-',fpout);
  69. return pCE;
  70.  
  71.  
  72. int main(int argc, const char * argv[]) {
  73.  
  74.  
  75. }//end of main
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:5:5: error: unknown type name 'CELL'
     CELL **ppCE;
     ^
prog.c: In function 'ReadMaze':
prog.c:20:29: error: lvalue required as left operand of assignment
     if ((MAZE *)0 == pMQRet = malloc(sizeof(MAZE)*1)) {
                             ^
prog.c:29:64: error: 'iRows' undeclared (first use in this function)
         if ((CELL *)0 == (pMQRet->ppCE = malloc(sizeof(CELL *)*iRows))) {
                                                                ^
prog.c:29:64: note: each undeclared identifier is reported only once for each function it appears in
prog.c:35:26: warning: comparison of distinct pointer types lacks a cast
             if ((CELL*)0 == pMQRet->ppCE[j] = malloc((pMQRet->iCols+1)* sizeof(CELL))){
                          ^
prog.c:35:45: error: lvalue required as left operand of assignment
             if ((CELL*)0 == pMQRet->ppCE[j] = malloc((pMQRet->iCols+1)* sizeof(CELL))){
                                             ^
prog.c:44:10: error: 'ppCE' undeclared (first use in this function)
         }ppCE[j][k] = c;
          ^
prog.c: At top level:
prog.c:46:2: error: expected identifier or '(' before 'return'
 }return pMQRet;
  ^
prog.c: In function 'PrintMaze':
prog.c:57:33: error: lvalue required as increment operand
     for (l=0;l<pMQThis->iCols+2;++1)
                                 ^
prog.c:60:13: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
         pCE = pMQThis->ppCE[j];
             ^
prog.c:63:27: error: 'cglyph' undeclared (first use in this function)
             fputc(pCE[k], cglyph,fpout);
                           ^
prog.c:63:19: error: incompatible type for argument 1 of 'fputc'
             fputc(pCE[k], cglyph,fpout);
                   ^
In file included from prog.c:1:0:
/usr/include/stdio.h:573:12: note: expected 'int' but argument is of type 'CELL {aka struct CEnode}'
 extern int fputc (int __c, FILE *__stream);
            ^
prog.c:63:13: error: too many arguments to function 'fputc'
             fputc(pCE[k], cglyph,fpout);
             ^
prog.c: At top level:
prog.c:68:7: error: expected declaration specifiers or '...' before '-'
 fputc('-',fpout);
       ^
prog.c:68:11: error: unknown type name 'fpout'
 fputc('-',fpout);
           ^
prog.c:69:1: error: expected identifier or '(' before 'return'
 return pCE;
 ^
prog.c: In function 'ReadMaze':
prog.c:46:1: warning: control reaches end of non-void function [-Wreturn-type]
 }return pMQRet;
 ^
stdout
Standard output is empty