Thread: Multiple syntax errors

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    14

    Multiple syntax errors

    Hey, I am trying to make a function for a larger battleship game, but I am getting errors that my TA didn't know how to fix either, so I thought I'd try my luck here.

    Code:
    #include <math.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    
    #define CARRIER_LENGTH 5
    
    void randomlyPlaceShipsOnBoard()
    {
    	int direction = 0, row = 0, column = 0, i = 0;
    
    	direction = rand() % 2;
    	
    	if (direction == 0)
    	{
    		column = rand() % 10;
    		row = rand() % 10 * (11-CARRIER_LENGTH); Error 7 is here
    	}
    	else
    	{
    		column = rand() % 10 * (11-CARRIER_LENGTH); Error 8 is here
    		row = rand() % 10;
    	}
    
    	while (i < CARRIER_LENGTH) Error 9 is here, which is confusing because there's no '='
    	{
    		if (gameBoard[row][column] != '~')
    		{
    			status = 1;
    		}
    		i++; Errors 10 and 11 are here
    		row++; Errors 12 and 13 are here
    	} Error 14 is here
    }
    The error messages are:

    Error 7 error C2059: syntax error : '='
    Error 8 error C2059: syntax error : '='
    Error 9 error C2059: syntax error : '='
    Error 10 error C2143: syntax error : missing '{' before '++'
    Error 11 error C2059: syntax error : '++'
    Error 12 error C2143: syntax error : missing '{' before '++'
    Error 13 error C2059: syntax error : '++'
    Error 14 error C2059: syntax error : '}'

    As always, the help is much appreciated, and I'm open to any suggestions for improvements..

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,794
    try "Rebuild all"

    what i get compling your code
    Code:
    1>test.c(27) : error C2065: 'gameBoard' : undeclared identifier
    1>test.c(27) : error C2109: subscript requires array or pointer type
    1>test.c(29) : error C2065: 'status' : undeclared identifier
    Last edited by vart; 03-25-2009 at 10:40 PM.
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  2. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. class errors
    By romeoz in forum C++ Programming
    Replies: 3
    Last Post: 09-16-2003, 07:57 PM
  5. header file bringing errors?
    By bluehead in forum Windows Programming
    Replies: 4
    Last Post: 08-19-2003, 12:51 PM