vsnprintf like

S

stef

Hello,

I would like to do my "own" printf.
Under C I used to play with the classic "vsnprintf" :

void print_it(char *app, size_t num, ...)
{
va_list arg;
char buf[1024];
...
va_start(arg, num);
vsnprintf(buf, ..., ..., arg);
...
}


How could I do that with Java ?


thanks for your help...
 
J

Joshua Cranmer

stef said:
Hello,

I would like to do my "own" printf.
Under C I used to play with the classic "vsnprintf" :

void print_it(char *app, size_t num, ...)

Using Java 5, the method header would look like:
void print_it(String app, Object ... args)

The args object would act like an array of Objects.
 
M

Mark Rafn

stef said:
I would like to do my "own" printf.

Why your "own", rather than a built-in one?
Under C I used to play with the classic "vsnprintf" :

Under 1.5 and later PrintStream has a format(String, Object...) method. This
is pretty close to the C printf methods. Or just use the java.util.Formatter
directly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top