Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Strings in GDK cant get them to work

Author
Message
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 11th Aug 2006 19:22
Im having a problem with getting a string to work here is a cutdown version of the code.


and here is the error


fubar
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 12th Aug 2006 09:38
This is a cutdown version of how i got it to work


fubar
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 13th Aug 2006 14:19
Whats Wrong with this code for a char*



fubar
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 13th Aug 2006 14:20
It dont like the dbloadimage command in GDK when i exit i get the following message



fubar
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 13th Aug 2006 14:25
Oh, dbLoadImage is fine - its your code thats the problem.

Dont exactly know what your trying to do, but this is inefficent :



Why not just do :



Come to the last Unofficial DBPro Convention (http://convention.logicstudios.net/)
Supplying "NO" since 1974...
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 13th Aug 2006 14:32
Its been too long since i have dabbled in c and i forget all about pointers ive been trying to familarize myself but still need to relearn heaps who would know i have a c prog certificate i certainly dont deserve it any more. I am really a noob again.

fubar
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 13th Aug 2006 14:47
I basically pass a parameter to the program known as the continent from this i want the program to load different a different heightfield, terrains etc

I had to cast it to get it to reference it as char * for strcpy and strcat but it still exits with the same error for sum unknown reason. I am not sure if i should be using namespace or malloc but i thought either code would have been valid. Maybe it just because i think im running in debug mode not sure.



fubar
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 13th Aug 2006 15:13
The only real problem I can see is that its possible your exceeding the 40 character limit - it would be better to use char loadThis[MAX_PATH]; (dont forget to #include "windows.h") instead.

Come to the last Unofficial DBPro Convention (http://convention.logicstudios.net/)
Supplying "NO" since 1974...
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 13th Aug 2006 17:01
Okay no probs i switched it to release version and its compiling and exiting properly only probs i cant get the dbBuildTerrain to work ive even tried removing the f float definer. code works until i do a dbBuildTerrain(1); if i comment out this line no problems

The Error i get is


fubar
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 13th Aug 2006 17:02
The terrain is a 512*512 png file

fubar
Kaiyodo
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: UK
Posted: 13th Aug 2006 17:06 Edited at: 13th Aug 2006 17:10
You can get rid of a those (char *) casts if you use 'loadThis' rather than '&loadThis' in all of your calls, there's no need to take the address of an array as it's already a pointer.

Oh, and the most likely reason for your code not crashing in Release is that the error checking is turned off
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 13th Aug 2006 17:13
okay thanks kaiyodo that makes sense now i just need to figure out why it hates my call dbBuildTerrain(1) by the way i did remove the char casting in the debugger i must admit it prefers the casts left in with strcpy and strcat because it cant properly cast a char [?] to char * thats what the debugger was notifying anyway

fubar
Kaiyodo
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: UK
Posted: 13th Aug 2006 17:33
Well a char [] is a char *, no conversion is needed. Whenever you get errors like that from the compiler then there's alway something else wrong, like not being able to convert a 'const' pointer to a non-const. Without the full error it's a bit difficult to guess what might be causing it

Sorry I can't help with the terrain problem, never used 'em.

Login to post a reply

Server time is: 2024-06-17 07:22:50
Your offset time is: 2024-06-17 07:22:50