printf vs. vprintf 
Author Message
 printf vs. vprintf

Please excuse if this is an old topic in this group, but i am a
novice in ANSI C.

Can anyone describe the advantages (or disadvantages) in using
vprintf instead of printf?

|-----------------------------------------------------------------------------|
|It`s not dead,          | Michael Illgner          | email to                |
|It justs smells funny ! | Theodorstr. 27           |                         |

|Life, Universe and all  | 05251/26488 or 60-2331   |                         |
------------------------------------------------------------------------------|
--

|-----------------------------------------------------------------------------|
|It`s not dead,          | Michael Illgner          | email to                |
|It justs smells funny ! | Theodorstr. 27           |                         |



Tue, 26 Jan 1993 20:00:48 GMT  
 printf vs. vprintf

Quote:
> Can anyone describe the advantages (or disadvantages) in using
> vprintf instead of printf?

I've never used vprintf, and I've been Cing for 7 years now!  (Jean-Pierre,
grand-pere has passed 93 happy years in Choiseul-sur-Mer without once using the
past anterior verb form. --New Yorker cartoon :-) )

But seriously: If you have written a function that takes a variable number of
arguments, and inside the function you want to printf those arguments, or all of
them after the first so many, you would call vprintf to do it.  vprintf takes
exactly two arguments, a char* for the format, and a va_list containing the
other arguments.  That's the only usse I know for vprintf.

So at the risk of oversimplifying: always use printf.  vprintf is used only in
very special circumstances, which you're not likely to meet.

Stan Brown, Oak Road Systems, (216) 371-0043
The opinions expressed are mine. Mine alone!  Nobody else is responsible for
them or even endorses them--except my cat Dexter, and he signed the power of
attorney only under my threat to cut off his Cat Chow!



Thu, 28 Jan 1993 01:56:54 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. (void)printf() vs. printf()

2. Re(2): Re(2): (void)printf() vs. printf()

3. Re(2): (void)printf() vs. printf()

4. replacing printf with my printf, then calling C lib's printf

5. cout vs printf()

6. printf vs fprintf

7. printf %p vs. %x

8. 2 printf's vs. a ternary

9. cout vs printf

10. printf vs fprintf

11. printf() vs. puts()

12. printf vs. cout

 

 
Powered by phpBB® Forum Software