Sscanf and floats
#1

Hi, I am using sscanf2 and I have a problem with loading floats from mysql database:

Code:
sscanf(query,"p<|>ds[50]s[24]ddddffffffd",
     		i,
      		Bizz[i][name],
       		Bizz[i][owner],
        	Bizz[i][status],
        	Bizz[i][type],
        	Bizz[i][vault],
        	Bizz[i][interior],
        	Bizz[i][intx],
        	Bizz[i][inty],
        	Bizz[i][intz],
        	Bizz[i][outx],
        	Bizz[i][outy],
        	Bizz[i][outz],
			Bizz[i][price]);
			
			printf("x: %f y: %f z: %f",Bizz[i][outx],Bizz[i][outy],Bizz[i][outz]);
In console, it prints only 0.0000000 etc... but in mysql log it shows real coordinates.. What could be the froblem?
Reply
#2

Can you show the 'enum' of the Bizz please.
Reply
#3

Code:
enum
{
	id,
	name[50],
	owner[24],
	status, 
	type, // 0 - n/a | 1 - shop | 2 - bar
	vault,
	interior,
	Float:intx,
	Float:inty,
	Float:intz,
	Float:outx,
	Float:outy,
	Float:outz,
	price
}
new Bizz[MAX_BIZZ][bizzinfo];
Reply
#4

pawn Code:
sscanf(query,"p<|>ds[50]s[24]ddddffffffd",
            i,
            Bizz[i][name],
            Bizz[i][owner],
            Bizz[i][status],
            Bizz[i][type],
            Bizz[i][vault],
            Bizz[i][interior],
            Bizz[i][intx],
            Bizz[i][inty],
            Bizz[i][intz],
            Bizz[i][outx],
            Bizz[i][outy],
            Bizz[i][outz],
        Bizz[i][price]
);
        printf("x: %f y: %f z: %f",Bizz[i][outx],Bizz[i][outy],Bizz[i][outz]);
I don't really think it's diffrent, but try.
Reply
#5

isn't that the same?
Reply
#6

pawn Code:
sscanf(query, ...
I assume you're using sscanf on the query itself ?
You should be using it on the data mysql_fetch_row_format yields.
Reply
#7

The rest of the info from enumeration loads, only coordinates are 0.000000 :/

edit: full code http://pastebin.com/qbuSFcAV
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)