C & C ++ library introduction (2)

Source: Internet
Author: User

Stream:ProgramAn abstraction between a member and a physical device. Text streams (character conversion may occur, for example, '/N' to'/n/R') and binary streams.
Files: physical devices, such as disk files, terminals, and printers.

All the streams are the same, but the files are not. The open flow operation is linked to a file.

File stream Io
1. open:
Fopen: open the file and return the stream related to the file. Text and binary. Read, write (generate, clear), attach, read/write (cache should be cleared between read/write)
Freopen: Associate an existing stream with a file.
2. input:
Fgetc and GETC: EOF at the end of the text, and feof () at the end of the binary ().
Fgets: ends with a line break or a specified number. A null character is added at the end of each read.
Fread: Read the specified number to the array.
Fscanf: formatted and read.
3. Output:
Fputc
Fputs and putc: write strings to files and discard null characters.
Fwrite
Fprintf
4. addressing:
Fseek: binary file, specified in bytes.
Fsetpos/fgetpos: Specifies the position, type: fpos_t.
Ftell: the number of bytes from the current position starting from the file.
Rewind: reset the file location pointer to the beginning of the file.
5. close:
Flose: close the file.
6. ungetc: returns a character to the current position of the file stream, which is the first character to be read next time.

Standard stream io1. input:
Getchar:
Gets:
Scanf:
2. Output:
Putchar:
Puts:
Printf: stdin and stdout are predefined file * streams, indicating standard input and output streams.

String Io
Sprintf
Snprintf
Sscanf

Buffer operation:
Fflush
Setbuf
Setvbuf

File Operations:
Remove:
Rename:
Tmpfile
Tmpnam

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.