Thread: A little problem here

  1. #1
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790

    A little problem here

    I am havi9ng some problem with some code. I am making up a text map for my game I have planned, and want to output it onto the screen.

    Code:
    #include <iostream.h>
    #include <stdio.h>
    #define PLAYER 3
    int i, j;
    int main()
    {
    
    	int grid[20][20] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
    		                 1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,
    						 1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    						 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    						 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    						 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    						 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    						 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    						 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    						 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    						 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    						 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    						 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    						 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    						 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    						 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    						 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    						 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    						 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    						 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0};
    
    
    
    grid[5][5] = PLAYER;
    
    
    for (i = 0; i < grid;i++)
    {
    	for (j = 0; j < grid; j++)
    	{
    	cout << grid[i][j];
    	}
    }
    
    
    		return 0;
    }
    here are the errors:
    Code:
    :\Program Files\DevStudio\MyProjects1\Game\Main.cpp(36) : error C2446: '<' : no conversion from 'int (*)[20]' to 'int'
                                                                            This conversion requires a reinterpret_cast, a C-style cast or function-style cast
    C:\Program Files\DevStudio\MyProjects1\Game\Main.cpp(38) : error C2446: '<' : no conversion from 'int (*)[20]' to 'int'
                                                                            This conversion requires a reinterpret_cast, a C-style cast or function-style cast
    thanks in advance

  2. #2
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    btw, if I just use a single cout call, I get a hexdecimal code.

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    you could do this, other people know more than i do, so maybe there is another way.

    Code:
    for (i = 0; i < 20;i++)
        {
            for (j = 0; j < 20; j++)

  4. #4
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Code:
    #include <iostream>
    #include <cstdio>
    
    const int PLAYER  = 3;
    const int GRID_SIZE = 20;
    
    int main()
    {
    
    	int grid[GRID_SIZE][GRID_SIZE] = { 
    					 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
    		                 	 1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,
    					 1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    					 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    					 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    					 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    					 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    					 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    					 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    					 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    					 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    					 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    					 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    					 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    					 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    					 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    					 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    					 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    					 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
    					 1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0
    					 };
    
    
    	grid[5][5] = PLAYER;
    
    
    	for (int i = 0; i < GRID_SIZE; i++)
    	{
    		for (int j = 0; j < GRID_SIZE; j++)
    		{
    			std::cout << grid[i][j];
    		}
    		std::cout << '\n';
    	}
    	return 0;
    }
    ???
    Last edited by Eibro; 02-12-2003 at 10:40 PM.

  5. #5
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    thanks, that worked, I guess it was just some bizzare MSVC thing.

  6. #6
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    you can't do
    Code:
    for(i = 0; i < grid; i++)
    because, I think (at least it makes sense to me), it doesn't know which size, if its rows or columns. you need to specify if it is rows or columns for grid.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM