Jump to content

Recommended Posts

I'm confused about printf. I don't know c++ and so never had to use it before leaning vex. I'm wondering about all letters you can use for the arguments in the printf function. I've seen %f used for a float. %d also used for float (decimal i guess), %s for string, and %i for integer. 

the docs state: The conversion of the argument is specified by a single letter: g, f, s, d, x, c, p.

it goes on to show: 

%g, %p, %c

Print an integer float, vector, vector4, matrix3, matrix or string in "general" form.

%f, %e, %E

Print a float, vector, vector4, matrix3 or matrix in floating point form.

The first example shows 3 argument types and 7 data types. Does this mean i can use any of the listed %letter arguments with any of the data types shown? 

Share this post


Link to post
Share on other sites

generally yes ;), %d will work with most "number" types same as %f, the difference between them is mostly formatting I think.

For instance with %d, it will limit the amount of decimals in the output string, whereas %f will try to keep as many digits behind the decimal point as possible.
There are some other tricks that you could use, such as %02d. that will pad the start of the output with zeros, so you can do a more easy alpha-numeric search for example :)

personally, I never had to use anything other than %f, %d or %s.

Edited by acey195
gramarz
  • Like 1

Share this post


Link to post
Share on other sites

Thanks a lot for your explanation. I think it should be added to the Houdini docs. :) much appreciated. 

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

×