|
-
Apr 19th, 2005, 06:59 PM
#1
Frenzied Member
Re: Arrays of structs with unspecified size
Sorry, my mistake, forgot the *.
sMap* sMapPtr=new sMap[runtime number does not have to be constant];
I don't know VB though so I can't help you converting snippet.
-
Apr 19th, 2005, 07:05 PM
#2
Thread Starter
Hyperactive Member
Re: Arrays of structs with unspecified size
Code:
sMAP* sMapPtr = new sMAP[mapwidth][mapheight];
my compiler still whines about how the array bound is not constant
and I get a different error too:
error C2440: 'initializing' : cannot convert from 'struct sMAP (*)[1]' to 'struct sMAP *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
-
Apr 19th, 2005, 08:19 PM
#3
Frenzied Member
Re: Arrays of structs with unspecified size
Don't try to make a 2 dimentional array. Treat it like a bitmap and do manual address translation like CB said.
sMAP* sMapPtr = new sMAP[mapwidth*mapheight];
-
Apr 20th, 2005, 06:47 AM
#4
Thread Starter
Hyperactive Member
Re: Arrays of structs with unspecified size
Hey, thanks!
When CornedBee spoke of manual address translation, I didn't think that he meant that, so thanks to the both of you!
-
May 4th, 2005, 01:28 PM
#5
Thread Starter
Hyperactive Member
Re: Arrays of structs with unspecified size
I find this quite strange... This method works very well when the compiler is set to C++, but when it is set to just C, it doesn't like what it sees... Is that because this is only a C++ method of doing that?
-
May 4th, 2005, 01:59 PM
#6
Frenzied Member
Re: Arrays of structs with unspecified size
new and delete are c++,
malloc and free are c and c++.
-
May 4th, 2005, 06:53 PM
#7
Thread Starter
Hyperactive Member
Re: Arrays of structs with unspecified size
I'm also having trouble with something else.. the scope of the pointer. Say I load the map, but in the same function I declare that pointer, as I get the mapwidth and mapheight variables from the file... I can't use that same pointer in a different function, like the Render function...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|