Sign in to follow this  
Sfpiano

sscanf problem

Recommended Posts

I have data stored in a char* as such" *data = " 3.3494229317 -0.0225959271 62.0168151855 ". When I make the call: sscanf(data, "%f %f %f", &D3DXVECTOR3); it only changes the x coordinate of the vector.

Share this post


Link to post
Share on other sites
You cannot do that. sscanf() works by analysing the provided parameters. Thus if you want to parse three floats you will have to provide three float pointers as well (also you need to pass variables, not a type!):
D3DXVECTOR3 v;
int result = sscanf(data, "%f %f %f", &v.x, &v.y, &v.z);
if (result != 3) {
// error parsing data
}

Share this post


Link to post
Share on other sites
i didn't think you could store data like that and have it be read as 3 floats.

i figured it was more along the lines of:

char *data[3] = {"3.3494229317", "-0.0225959271", "62.0168151855"};


edit: i guess i misread sorry....

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this