20.11.2016, 07:44
Hello, i have a sscanf custom specifiers to check if gang name is exists.
Here is my code:
The problem is, it doesn't work while i'm trying to find a gang that have spaces in it.
I've debugged that code by printing "string" variable, and i found out that the string is getting cut off at space.
Is there any way to fix this / to make it works?
Thanks in advance.
Here is my code:
Код:
SSCANF:gang(string[]) { printf("SSCANF:gang string is \"%s\"", string); new ret; if ('0' <= string[0] <= '9') { ret = strval(string); if(Iter_Contains(Gangs, ret)) return ret; } foreach(new i : Gangs) { if(!strcmp(g_Gang[i][gname], string, true)) return i; } return -1; }
I've debugged that code by printing "string" variable, and i found out that the string is getting cut off at space.
Код:
new testname[12] = "Gang name", id; sscanf(testname, "k<gang>", id); // Prints SSCANF:gang string is "Gang" testname = "Gang_name"; sscanf(testname, "k<gang>", id); // Prints SSCANF:gang string is "Gang_name"
Thanks in advance.