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 / Buffer Overrun problem

Author
Message
archie456
16
Years of Service
User Offline
Joined: 13th Feb 2008
Location:
Posted: 2nd Mar 2008 21:22
Hi,

I've written a small program which animates a sprite on the screen and moves it around with the arrow keys.

All works fine, apart from when I exit (i.e. click the close icon) Visual C++ 2008 Express Edition given an error "A buffer overrun has occurred which has corrpted the program's internal state..."

In the main LoopGDK I have two IF statements which collect keyboard input thus:

if (dbRightKey () == 1)

if (dbLeftKey () == 1)

Any ideas why I'm getting this error?


Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 2nd Mar 2008 23:21
the problem is here dbText(0, 0, message);

you need to empty message every time its shown. I can see that you only give space for 100 char.

Been there

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine (thanks kBessa)
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 3rd Mar 2008 09:55
I don't see any problem there, but I'd suggest you replace itoa with a standard C++ function, perhaps sprintf:



archie456
16
Years of Service
User Offline
Joined: 13th Feb 2008
Location:
Posted: 3rd Mar 2008 22:24
Thanks for the replies;
I think that Niels is correct as when I comment out the message display part I don't get the error.

What do you mean by empty the message everytime? Do you mean;

delete message;

or

message[]="";

by the way message[]=""; states error c2059; syntax error: ']'.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 4th Mar 2008 18:18 Edited at: 4th Mar 2008 18:19
hmmm... I think you need a class like this one I'm posting or learn about dynamic memory, static char buffers, and the string lib or something.

My Class is a home brew string class whos advantage is in its simplicity. Correct? Many will say Bad Form! Does it Work? Yup. Easy? Yup. Lean? YUP... Perfect? Well.. doesn't crash unless you mess up terribly. Its been working for in MILES and MILES of code.

jfc_string.h


jfc_string.cpp



Then you can do something like this:


There isn't a lot of things in that class so its to learn and I find I USUALLY don't need more than the basics in game dev.




And if you take these two files and include them...
jfc_common.h


jfc_common.cpp


(Aside from a global interpolate routine you don't need now) you'll have a GLOBAL 1024 byte buffer you can use in your code anywhere. Example:



[edit] Fixed filenames and some typos I had in bold... [/edit]

Login to post a reply

Server time is: 2024-11-20 03:31:16
Your offset time is: 2024-11-20 03:31:16