SSCANF storing weird numbers?
#1

Well SSCANF enum is returning weirdd numbers, but in the mysql_log its retrieving the info correctly.

pawn Код:
enum pInfos
{
      Info1, // ID
      Info2[24], //username
      Info3[50], //PW
      Info4,
      Info5,
      Info6,
      Info7,
      Info8,
      Info9,
      Info10,
      Info11,
      Info12[30],
      Info13,
      Info14,
      Info15,
      Info16[128]
};
new store[pInfos];

//sscanf line
new row[500];
sscanf(row, "p<|>e<ds[100]s[100]ddddddds[100]dds[100]ds[100]>", store[Info1],store[Info2],store[Info3],store[Info4],store[Info5],store[Info6],store[Info7],store[Info8],store[Info9],store[Info10],store[Info11],store[Info12],store[Info13],store[Info14],store[Info15],store[Info16]);

I had it print the values, and it was like.. 78,79, 80, then up.. Going in order like that.
Reply
#2

Check this example:

pawn Код:
enum
    E_DATA
{
    E_DATE_C,
    Float:E_DATA_X,
    E_DATA_NAME[32],
    E_DATA_Z
}

main
{
    new
        var[E_DATA];
    sscanf("1 12.0 Bob c", "e<ifs[32]c>", var);
}
Reply
#3

use the correct string size instead of 100?
Reply
#4

Quote:
Originally Posted by [L3th4l]
Посмотреть сообщение
Check this example:

pawn Код:
enum
    E_DATA
{
    E_DATE_C,
    Float:E_DATA_X,
    E_DATA_NAME[32],
    E_DATA_Z
}

main
{
    new
        var[E_DATA];
    sscanf("1 12.0 Bob c", "e<ifs[32]c>", var);
}
ok.. changed it to just store, at end of the sscanf input.

Now its just returning 0 on everything
Reply
#5

1.Witch one sscanf?

1)1.0 That you have in script
2)or 2.0 that is the plugin
Reply
#6

2.0.. the plugin
Reply
#7

Код:
sscanf(row, "e<p<|>ds[100]s[100]ddddddds[100]dds[100]ds[100]>", store);
Try that


edit: Also, try putting it in an if statement to help with error checking. Something like:

Код:
if(sscanf(row, "e<p<|>ds[100]s[100]ddddddds[100]dds[100]ds[100]>", store))
{
    // Cant parse data 
}
else
{
    //All is well
}
edit2: Chnage the string sizes in sscanf as someone previously said. You can not have them higher than the original array's length; this will cause a nasty buffer overflow.
Reply
#8

everything still returning 0 Kyo
Reply
#9

ok i put in an if statement, i put print("i cant bla bla"); under first brackets, and put the rest of the good script, under the else statement.

And its not going to else, is stopping at // cant parse data
Reply
#10

Quote:
Originally Posted by DiddyBop
Посмотреть сообщение
ok i put in an if statement, i put print("i cant bla bla"); under first brackets, and put the rest of the good script, under the else statement.

And its not going to else, is stopping at // cant parse data
Ok here's the fixed version:

Код:
sscanf(row,"e<p<|>ds[24]s[50]dddddddds[30]ddds[128]>",store)
shove it in your if statement and test. If it doesn't work, i need you to print out "row" for us (one guess would be that your not using a delimiter in row at all (well, i mean you're using space not | :P)).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)