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 / Garbage behind a char array

Author
Message
DeadTomGC
13
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 4th Aug 2011 01:03
I working on a side scrolling engine and am using this console application to test a few things. Can anyone explain the output I am getting? It usually looks like this: level001.txt*^$$%@#%



Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 4th Aug 2011 01:18 Edited at: 4th Aug 2011 01:18
A string MUST be NULL terminated. The last char should be \0.
What's the point with the \ marks (temp[0]=\'l\')? What compiler are you using? Normally I would simply do it like this:


sprintf(....) and strcpy(....) will NUMM terminate the string automatically. Alternatively, you could simply make the char size one larger (char temp[13] and make temp[12]='\0';

The fastest code is the code never written.
DeadTomGC
13
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 4th Aug 2011 01:39
Quote: "What's the point with the \ marks (temp[0]=\'l\')?"

Wow! That is not in my code. get rid of all those.

Ok, I got it. Thanks!


Login to post a reply

Server time is: 2024-05-07 07:26:21
Your offset time is: 2024-05-07 07:26:21