How to add zeros to a variable in oF?

I’m coming to oF from Processing. I’m populating an array and want to add zeros to the beginning of each element. In Processing I use the nf() function What is the equivalent in openFramworks? And how is it used? Thanks.

Hi jarednielsen,

You can create your own nf function like this

string nf(string format, int number) {  
    char buffer[100];  
    sprintf(buffer, format.c_str(), number);  
    return (string)buffer;  

you can use it like this:

int i = 1234;  
string s = nf("%05d", i);  

Good luck!