AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   strlen not working (https://forums.alliedmods.net/showthread.php?t=309397)

BaD CopY 07-24-2018 12:09

strlen not working
 
PHP Code:

    new const String[] = "abcd";
 
    new 
len strlen(String);
    
    for(new 
0leni++) {
        
console_print(0"%s"String[i]);
    } 

console output:

Code:

abcd
abc
ab
a

for String[0] it prints "abcd" :O

klippy 07-24-2018 12:11

Re: strlen not working
 
It is working correctly. If you want to print a single character use "%c" instead.

BaD CopY 07-24-2018 12:13

Re: strlen not working
 
Thank you, I didnt know that :D

Ghosted 07-24-2018 13:44

Re: strlen not working
 
Quote:

Originally Posted by BaD CopY (Post 2605898)
console output:
Code:

abcd
abc
ab
a



How u got that when index is increasing ?

Correct is:


Code:

abcd
bcd
cd
d


BaD CopY 07-24-2018 14:22

Re: strlen not working
 
Quote:

Originally Posted by Ghosted (Post 2605928)
How u got that when index is increasing ?

Correct is:


Code:

abcd
bcd
cd
d


You are right.. remembering error :D

Natsheh 07-24-2018 15:05

Re: strlen not working
 
Mark as solved.

fysiks 07-24-2018 21:14

Re: strlen not working
 
You need to learn how to do some basic debugging. If you think there is something wrong with strlen() then you should have determined the value that was actually being provided by strlen(). If you did that then you would know that there is nothing wrong with strlen().


All times are GMT -4. The time now is 12:49.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.