Register | Login
Forum Index > Bugs and Fixes > possible bug with strCopyLen
Author Message
Pages: 1
Molotov
Member
(send private message)

Posts: 49
Topics: 21

Location:
Behind Keyboard
[947] possible bug with strCopyLen - posted: 2011-12-02 18:37:36
when is was printing the information copied i keept getting some jibberish, like it was reading past the mem used for that string. so i made this to test and as i suspected, seems like strcopylen doesn´t add 0 at the end of the buffer


Code:
program WIN32CUI 'Test';

#include 'ch.zir';
#include 'fileio.zir';
#include 'strings.zir';

char curVar[25], server_name[25];

strCopyLen(@curVar, 'testing a thing here', 20);
strCopyLen(@curVar, 'name', 4);


strLen(@curVar);
strCopyLen(@server_name,@curVar, eax);
print('curVar= ',@curVar, '\r\n');

wait_key(nil);

ExitProcess(0);


prints


Code:
curVar= namening a thing here



"Lerning new things is what life is all about, if you are always doing the same old things day in and day out you might aswell just kill yourself." - ME d^_^b
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[948] - posted: 2011-12-02 18:58:10
Code:
strCopyLen(@curVar, 'testing a thing here', 21);
strCopyLen(@curVar, 'name', 5);


this will output

curvar = name;

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[949] - posted: 2011-12-02 19:00:58
just to note that 'const strings' have an auto null byte, so if you want to append that too you need to add the extra 1 char size.

a sample scenario:

var1 = 'testing';

Code:
strCopyLen(@var1, 'post', 4);


var1 will now equal "posting"

but....

Code:
strCopyLen(@var1, 'post', 5);


var1 will equal "post"

hope this helps.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Molotov
Member
(send private message)

Posts: 49
Topics: 21

Location:
Behind Keyboard
[950] - posted: 2011-12-02 19:02:18
ah thanks.. =)

"Lerning new things is what life is all about, if you are always doing the same old things day in and day out you might aswell just kill yourself." - ME d^_^b
Pages: 1
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 6 user(s) online. 0 member(s) and 6 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd