DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 12th September 2011
xmorg xmorg is offline
Real Name: Tim Cooper
Fdisk Soldier
 
Join Date: Sep 2010
Location: San Diego
Posts: 56
Default 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
Here is how its setup. First there are the structs
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;
Then a function named "worldgen"
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));
    }
....somewhere within my "for loop"
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...
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT. The time now is 10:19 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick