Vfprintf, vprintf, and vsprintf Functions

Source: Internet
Author: User

I. vfprintf

Function Name: vfprintf

Function: formatted data is output to the specified data stream.

Usage: int vfprintf (File * stream, char * format, va_list PARAM );

Function Description: vfprintf () will convert and format the data according to the format string, and then output the result to the file specified by the parameter stream until the string ends ('/0 ') so far. For the format of the format string, see printf ().

Return Value: the number of actual output characters is returned if the request is successful, and-1 is returned if the request fails. The error cause is stored in errno.

Program example:

File * FP; <br/> int vfpf (char * FMT ,...) <br/>{< br/> va_list argptr; <br/> int CNT; <br/> va_start (argptr, FMT); <br/> CNT = vfprintf (FP, FMT, argptr); <br/> va_end (argptr); <br/> return (CNT); <br/>}< br/> int main (void) <br/>{< br/> int inumber = 30; <br/> float fnumber = 90.0; <br/> char string [4] = "ABC "; <br/> fp = tmpfile (); <br/> If (FP = NULL) <br/> {<br/> perror ("tmpfile () call "); <br/> exit (1); <br/>}

 

Ii. vprintf Functions

Function Name: vprintf

Function: Send formatted output to stdout.

Usage: int vprintf (char * format, va_list PARAM );

 

Iii. vsprintf Functions

Function: Send formatted output to the string

Usage: int vsprintf (char * string, char * format, va_list PARAM );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.