pass error before char

This is a discussion on pass error before char within the C Programming forums, part of the General Programming Boards category; Hey guys could i get some help im getting an error saying "pass error before char" but i cant see ...

  1. #1
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252

    pass error before char

    Hey guys could i get some help im getting an error saying "pass error before char"
    but i cant see any syntax errors?


    Code:
    #include "mine.h"
    #define UNKNOWN '?'
    
    /****************************************************************************
    * Function main() is the entry point for the program.
    ****************************************************************************/
    int main(void)
    {
       /* Stores all hidden data about the minefield. */
       char minefield[MAX_GRID][MAX_GRID];
       /* A version of the minefield that only stores known information. */
       char displayGrid[MAX_GRID][MAX_GRID]=
       {{'?'},{'?'},{'?'},{'?'},
       {'?'},{'?'},{'?'},{'?'},
       {'?'},{'?'},{'?'},{'?'},                 
       {'?'},{'?'},{'?'},{'?'}};
       
        /* Number of cells in each row and column used. */
       unsigned size = 0; 
       displayMinefield(char displayGrid[MAX_GRID][MAX_GRID], unsigned size);
       
    
    
       return EXIT_SUCCESS;
    }
    
    
    /****************************************************************************
    * Function init() initialises the "minefield" array with BLANK characters,
    * and the "displayGrid" array with UNKNOWN characters. These constants (and
    * others) are obtained from the header file.
    ****************************************************************************/
    void init(char minefield[MAX_GRID][MAX_GRID], 
              char displayGrid[MAX_GRID][MAX_GRID])
    {
    }
    
    
    /****************************************************************************
    * Function getSize() prompts the user for the size of the minefield in the
    * range MIN_GRID to MAX_GRID. Example:
    * ------------------------------------------------------
    * Enter minefield size (2-16): 6
    * You have chosen a minefield with 6 rows and 6 columns.
    * ------------------------------------------------------
    ****************************************************************************/
    unsigned getSize()
    {
      return EXIT_SUCCESS;
    }
    
    
    /****************************************************************************
    * Function placeMines() places a number of mines in the minefield. The 
    * number of mines placed is equal to the number of squares in the minefield
    * multiplied by the MINE_DENSITY constant.
    * For example, a grid with size 6 has 36 squares.
    * 36 x 0.16 = 5.76 or approximately 6 mines. (Result is always rounded up.)
    * The mines are placed at random positions and each mine must be in a 
    * different square. Use the MINE constant to mark mine squares. Use numbers
    * from 1-8 to mark other squares that have that number of mines adjacent to
    * them. Squares that don't have adjacent mines are marked as BLANK.
    * Here's an example:
    * ---------------------------
    *     1   2   3   4   5   6
    *   +---+---+-displayMinefield(char displayGrid[MAX_GRID][MAX_GRID], unsigned size);--+---+---+---+ [ EXAMPLE 1]
    * a | M | M | 1 |   |   |   |
    *   +---+---+---+---+---+---+
    * b | 2 | 2 | 1 |   |   |   |
    *   +---+---+---+---+---+---+
    * c |   |   | 1 | 1 | 1 |   |minefield[MAX_GRID][MAX_GRID]
    *   +---+---+---+---+---+---+
    * d |   |   | 2 | M | 2 |   |
    *   +---+---+---+---+---+---+
    * e |   |   | 3 | M | 4 | 1 |
    *   +---+---+---+---+---+---+
    * f |   |   | 2 | M | M | 1 |
    *   +---+---+---+---+---+---+
    * ---------------------------
    ****************************************************************************/
    void placeMines(char minefield[MAX_GRID][MAX_GRID], unsigned size)
    {
    }
    
    
    /****************************************************************************
    * Function displayMinefield() shows the user an ascii-art drawing of the
    * minefield with only known information displayed. Initially, nothing is
    * known about the minefield, so all squares are hidden. Example:
    * ---------------------------
    *     1   2   3   4   5   6
    *   +---+---+---+---+---+---+ [ EXAMPLE 2]
    * a | ? | ? | ? | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * b | ? | ? | ? | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * c | ? | ? | ? | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * d | ? | ? | ? | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * e | ? | ? | ? | ? | ? | ? |minefield[MAX_GRID][MAX_GRID]
    *   +---+---+---+---+---+---+
    * f | ? | ? | ? | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * You have flagged 0/6 mines.
    * ---------------------------
    ****************************************************************************/
    void displayMinefield(char displayGrid[MAX_GRID][MAX_GRID], unsigned size)
    {
        /*printf("Welcome to Minesweeper\n\n");
        printf("%c-%c\n", displayGrid[0][1],displayGrid[0][2]);*/
    
    }
    
    
    /****************************************************************************
    * Function guessType() prompts the user for a single character representing
    * one of three options. These options are used in the processGuess() 
    * function. Example:
    * --------------------------------------------------
    * Enter guess type ((f)lag, (u)ncover or (s)weep): u
    * You have selected "uncover".
    * --------------------------------------------------
    ****************************************************************************/
    char guessType()
    {
      char type;
      return type;
    }
    
    
    
    /****************************************************************************
    * Function guessSquare() prompts the user for the reference of a square 
    * in the minefield. The row and column components are extracted and made
    * available to the calling function separately. Example:
    * ------------------------------------------
    * Enter square (a1-f6): f1
    * Your have selected row "f" and column "1".
    * ------------------------------------------
    ****************************************************************************/
    void guessSquare(char* row, unsigned* col, unsigned size)
    {
    }
    
    /****************************************************************************
    * Function processGuess() manipulates the displayGrid variable and determines
    * if the Minesweeper game is over or not. It processes the three types of
    * actions called "(f)lag square", "(u)ncover square", and "(s)weep square".
    * Examples:?,?,?,?,?,?,
                                               ?,?,?,?,?,?,
                                               ?,?,?,?,?,?,
    					   ?,?,?,?,?,?,
    					   ?,?,?,?,?,?,
    					   ?,?,?,?,?,?};  
    					
    *
    * Consider the following minefield ("minefield" variable):
    * ---------------------------
    *     1   2   3   4   5   6
    *   +---+---+---+---+---+---+ [ EXAMPLE 3]
    * a | M | M | 1 |   |   |   |
    *   +---+---+---+---+---+---+
    * b | 2 | 2 | 1 |   |   |   |
    *   +---+---?,?,?,?,?,?,
                                               ?,?,?,?,?,?,
                                               ?,?,?,?,?,?,
    					   ?,?,?,?,?,?,
    					   ?,?,?,?,?,?,
    					   ?,?,?,?,?,?};  
    					+---+---+---+---+
    * c |   |   | 1 | 1 | 1 |   |
    *   +---+---+---+---+---+---+
    * d |   |   | 2 | M | 2 |   |
    *   +---+---+---+---+---+---+
    * e |   |   | 3 | M | 4 | 1 |
    *   +---+---+---+---+---+---+
    * f |   |   | 2 | M | M | 1 |
    *   +---+---+---+---+---+---+
    * ---------------------------
    * Initially, the minefield is entirely hidden ("displayGrid" variable):
    * ---------------------------
    *     1   2   3   4   5   6
    *   +---+---+---+---+---+---+ [ EXAMPLE 4]
    * a | ? | ? | ? | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * b | ? | ? | ? | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * c | ? | ? | ? | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * d | ? | ? | ? | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * e | ? | ? | ? | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * f | ? | ? | ? | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * ---------------------------
    * If the user decides to "uncover square f1", the following can happen:
    * - If a mine is accidentally uncovered, the game is lost.
    * - If a numbered square is uncovered, this is marked in the "displayGrid"
    *   variable?,?,?,?,?,?,
                                               ?,?,?,?,?,?,
                                               ?,?,?,?,?,?,
    					   ?,?,?,?,?,?,
    					   ?,?,?,?,?,?,
    					   ?,?,?,?,?,?};  
    					.
    * - If a blank square is uncovered, this is marked in the "displayGrid" 
    *   variable and all adjacent blank squares above, below, left, or right
    *   are also marked.
    * In this example, square f1 is blank, so the "displayGrid" variable is
    * updated to look like this:
    * ---------------------------
    *     1   2   3   4   5   6
    *   +---+---+---+---+---+---+ [ EXAMPLE 5]
    * a | ? | ? | ? | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * b | 2 | 2 | 1 | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * c |   |   | 1 | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * d |   |   | 2 | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * e |   |   | 3 | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * f |   |   | 2 | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * ---------------------------
    * From the above information, the user can already deduce where five of the
    * six mines are located. They are in squares a1, a2, d4, e4, and f4. So, the
    * user would next want to "flag square a1" and the other four squares. 
    * The user can only flag squares on unknown squares. So, our "displayGrid"
    * variable now looks like this:
    * ---------------------------
    *     1   2   3   4   5   6
    *   +---+---+---+---+---+---+ [ EXAMPLE 6]
    * a | F | F | ? | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * b | 2 | 2 | 1 | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * c |   |   | 1 | ? | ? | ? |
    *   +---+---+---+---+---+---+
    * d |   |   | 2 | F | ? | ? |
    *   +---+---+---+---+---+---+
    * e |   |   | 3 | F | ? | ? |
    *   +---+---+---+---+---+---+
    * f |   |   | 2 | F | ? | ? |
    *   +---+---+---+---+---+---+
    * ---------------------------
    * The user can now deduce that there are no mines in squares a3, a4, b4, and
    * c4. The user can now uncover these squares one at a time if he or she
    * wishes. However, this is somewhat inefficient. Alternatively, the user may
    * want to "sweep" around a numbered square that is considered safe because 
    * the adjacent mines have been (hopefully) correctly flagged.
    * So the user can "sweep square b3". This effectively executes the "uncover"
    * command on the surrounding 8 squares (but only the ones that are marked as
    * UNKNOWN). After performing the "sweep square b3" command, the "displayGrid"
    * variable looks like this:
    * ---------------------------
    *     1   2   3   4   5   6
    *   +---+---+---+---+---+---+ [ EXAMPLE 7]
    * a | F | F | 1 |   |   |   |
    *   +---+---+---+---+---+---+
    * b | 2 | 2 | 1 |   |   |   |
    *   +---+---+---+---+---+---+
    * c |   |   | 1 | 1 | 1 |   |
    *   +---+---+---+---+---+---+
    * d |   |   | 2 | F | 2 |   |
    *   +---+---+---+---+---+---+
    * e |   |   | 3 | F | 4 | 1 |
    *   +---+---+---+---+---+---+
    * f |   |   | 2 | F | ? | 1 |
    *   +---+---+---+---+---+---+
    * ---------------------------
    * The user can now flag the final mine at square f5. When all 6 mines are
    * flagged, the user guesses are verified. If any guess is incorrect, then
    * the user loses and the game is over. Otherwise the user wins the game and 
    * the game is over. The displayMinefield() function is called one last time
    * with bad guesses marked as BAD_GUESS.
    *
    * This function is a large one, and it is recommended that you further
    * modularise it. Leave this one until you have implemented the other six
    * major functions. Additionally, you should implement the three commands in
    * this order: flag, uncover, sweep.
    ****************************************************************************/
    int processGuess(char minefield[MAX_GRID][MAX_GRID], 
                     char displayGrid[MAX_GRID][MAX_GRID],
                     unsigned size, char type, char row, unsigned col)
    {
       return EXIT_SUCCESS;
    }
    
    
    /****************************************************************************
    * Function readRestOfLine() is used for buffer clearing. Source: 
    * https://inside.cs.rmit.edu.au/~sdb/teaching/C-Prog/CourseDocuments/
    * FrequentlyAskedQuestions/
    ****************************************************************************/
    void readRestOfLine()
    {
       int c;
    
       /* Read until the end of the line or end-of-file. */   
       while ((c = fgetc(stdin)) != '\n' && c != EOF)
          ;
    
       /* Clear the error and end-of-file flags. */
       clearerr(stdin);
    }

  2. #2
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    Quote Originally Posted by bazzano
    Code:
    displayMinefield(char displayGrid[MAX_GRID][MAX_GRID], unsigned size);
    You cannot call functions with the type of the parameters.

  3. #3
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    pass error?

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Code:
    char displayGrid[MAX_GRID][MAX_GRID]=
       {{'?'},{'?'},{'?'},{'?'},
       {'?'},{'?'},{'?'},{'?'},
       {'?'},{'?'},{'?'},{'?'},                 
       {'?'},{'?'},{'?'},{'?'}};
    This doesn't seem like a quadratic initialization list. Depending on compiler it may still work though.

    pass error?
    Parse?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 06-30-2005, 08:03 AM
  2. Passing structures... I can't get it right.
    By j0hnb in forum C Programming
    Replies: 6
    Last Post: 01-26-2003, 10:55 AM
  3. String sorthing, file opening and saving.
    By j0hnb in forum C Programming
    Replies: 9
    Last Post: 01-23-2003, 12:18 AM
  4. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 04:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21