5th Chapter Standard I/O Library summary

Source: Internet
Author: User

1 fwide function attempts to set the direction of a stream (the orientation of a stream determines whether a read-write single-byte or multibyte character)

int fwide (FILE *fp,int mode) wide-directional return positive value, byte-oriented return negative value, 0 for directional return
Directed stream does not change the orientation of the stream


2 The length of the buffer specified in the SETBUF function is bufsiz, and this constant is defined in stdio.h

3 Freopen and Fdopen functions

FILE *freopen (char *pathname,constchar *type,file *FP)

FILE *fdopen (int filedes,constchar *type)

3 gets and fgets, puts, and fputs functions

Char *fgets (char *buf,int n,file *fp)char *gets (char *buf)  int fputs (constchar *str,file *fp)int puts (const Char *str)

The Get function cannot specify a buffer length, which may result in storage space after it is written to the buffer
The puts function adds a line break

42 Binary I/O

size_t fread (void *buf,size_t size,size_t n,file *fp) size_t fwrite (constvoid *ptr , size_t size,size_t n,file *FP)

5 Locating the Stream
The position in the stream can be represented by a long, off_t, and fpos_t three types, corresponding to three kinds of functions for locating and setting the current position of the stream.

Long

long ftell (file *fp)int fseek (file *fp,long offset,int whence)

off_t:

off_t Ftell (FIEL *fp)int fseeko (FILE *fp,off_t offset,int whence)

pos_t:

int fgetpos (file *fp,fpos_t *POS)int fsetpos (file *fp,const fpos_t *pos)

6 Formatting I/O

Formatted output: printf, fprintf, sprintf, snprintf (can specify buffer length n compared to sprintf, overflow over length)

vprintf, vfprintf, vsprintf, vsnprintf

Formatted input: scanf, fscanf, sscanf

VSCANF, VFSCANF, vsscanf

5th Chapter Standard I/O Library summary

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.