strtok problem? Oo
I got some problems with that native. My path is "radio/ct_affirm.wav" and I would like to split the folder and the file name, so I used strtok with "/". It has also a function, to check if there are two folders (szOtherFolder). But I don't understand why it bugs.
PHP Code:
#include <amxmodx>
#define PLUGIN "test" #define VERSION "1.0" #define AUTHOR "bibu"
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_clcmd("say /string", "string") }
public string(id) { new szValue[64] = "radio/ct_affirm.wav" if(contain(szValue, "/")) { new szFolder[16] log_amx("* szValue contains a '/'") strtok(szValue, szFolder, charsmax(szFolder), szValue, charsmax(szValue), '/') log_amx("* szFolder: %s", szFolder) log_amx("* szValue: %s", szValue) if(contain(szValue, "/")) { new szOtherFolder[8] log_amx("* szValue contains another '/'") strtok(szValue, szOtherFolder, charsmax(szOtherFolder), szValue, charsmax(szValue), '/') log_amx("* szOtherFolder: %s", szOtherFolder) log_amx("* szValue: %s", szValue) } } }
This is the output:
Quote:
L 01/09/2013 - 20:32:17: [string_strtok_test.amxx] * szValue contains a '/'
L 01/09/2013 - 20:32:17: [string_strtok_test.amxx] * szFolder: radio
L 01/09/2013 - 20:32:17: [string_strtok_test.amxx] * szValue: ct_affirm.wav
L 01/09/2013 - 20:32:17: [string_strtok_test.amxx] * szValue contains another '/'
L 01/09/2013 - 20:32:17: [string_strtok_test.amxx] * szOtherFolder: ct_affi
L 01/09/2013 - 20:32:17: [string_strtok_test.amxx] * szValue:
bibu : /string
|
|