AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How do I print EACH character from an array? (https://forums.alliedmods.net/showthread.php?t=27655)

Geesu 04-26-2006 10:30

How do I print EACH character from an array?
 
In C I would just do something like:

Code:
                for ( new i = 0; i < strlen(data); i++ )                 {                     server_print( "%s", data[i] );                 }

But in Pawn this doesn't work, what do I have to do to print each CHARACTER from the array?

Thanks,
Josh

p3tsin 04-26-2006 10:33

Quote:

Originally Posted by Greenberet
Code:
new filename[200], len if(read[i3]!='[') {     len += format(filename[len],199-len,"%c",read[i3]) }

so replace %s with %c :)

Geesu 04-26-2006 10:43

ok so I try the following code:

Code:
                server_print( "%s", data );                                 for ( new i = 0; i < strlen(data); ++i )                 {                     server_print( "%c", data[i] );                 }                 server_print( "done" );

and the result:

Quote:

mysql_amxx_i386.so




















done
Why doesn't it print the characters ???

v3x 04-26-2006 10:44

Ahem!
Code:
new len = strlen(data); // <----- !! for(new i = 0; i < len; i++) {   server_print( "%c", data[i] ); }
Note: This will not help solve your problem ( at least I don't think it will ). It's just better-er..er.

Geesu 04-26-2006 10:45

LOL yes I know... I want to solve my problem!!!

Geesu 04-26-2006 10:47

haha that fixed it, thanks v3x

v3x 04-26-2006 10:49

Do I own or what?

... wait ... what part?


All times are GMT -4. The time now is 05:01.

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