Convert string with numbers into numbers only?
#6

Well that won't work like I said, since strval will just give you the integer value of the string, not extract numbers from it.

Although you could use a split function, to split the string by spaces, a rough example using sscanf by ******.

pawn Код:
new string[2][10], score;
File: hsfile = fopen("/Top5/Top5.ini", io_read);
fread(hsfile, tmp, 128);
sscanf(tmp,"s[10]s[10]",string[0],string[1]);

printf("MyName: %s || MyScore: %d",string[0],strval(string[1]));
You could also use sscanf to immediately store the score as an integer, like this:

pawn Код:
sscanf(tmp,"s[10]d",string,score);
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)