|
Programming C, bash, Python, Perl, PHP, Java, you name it. |
|
Thread Tools | Display Modes |
|
|||
Pointer to structs, C
Im getting an error when compiling my little "roguelike" attempt game
Code:
gcc -o rogue -lncurses *.c maps.c: In function 'worldgen': maps.c:131: error: incompatible type for argument 1 of 'regiongen' *** Error code 1 Code:
typedef struct s_region { long width; long height; char *mapname; char **data; } region; typedef struct s_worldmap { long width; long height; char *mapname; char **data; //The characters of the map. //Region structs. region **wregions; //a w*h array of regions } worldmap; Code:
int worldgen(worldmap *wm, int height, int width, int mtype) { .... wm = (worldmap *)malloc( sizeof(worldmap) ); wm->wregions = (region **) malloc(wm->height * sizeof(region *)); //REGIONS for(i = 0; i < height; i++) { wm->wregions[i] = (region *) malloc(wm->width * sizeof(region)); } regiongen(wm->wregions[y][x], wm->height, wm->width, wm->data[y][x]); regiongen's prototype int regiongen(region *rm, int height, int width, char maptype); my question is, is the argument, wm->wregions[y][x] not a pointer to struct? Last edited by ocicat; 12th September 2011 at 06:18 AM. Reason: Using [code] & [/code] tags makes life simpler on your readers... |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenBSD OpenBSD Reliability Fix: kernel NULL pointer dereference in getsockopt() | J65nko | News | 0 | 28th October 2009 11:56 PM |
c++: writing to the *this pointer? | robbak | Programming | 2 | 23rd October 2009 06:12 PM |