UNIX standard file programming libraries commonly used functions

Pointer to a file: 1, FILE

2, FILE * fopen (const char * filename, const char * type): Open or create a file and returns a pointer type FILE

3, FILE * freopen (const char * filename, const char * type, FILE * stream): to achieve the replacement file stream, closed the original flow stream, and then to fopen way to open a new file stream, successful return FILE, failure return NULL

4, int fclose (FILE * stream): close the file stream stream, the successful return 0, error return EOF

5, int remove (const char * filename): Delete string filename specified folder or directory

6, int rename (const char * oldname, const char * newname): Change the file name for the new file name newname oldname

7, int getc (FILE * stream): read the file input stream in the first character stream, and returns after the character is converted into an integer, while the file pointer to a character

8, int getchar (void): the same as getc

9, int fgetc (FILE * stream): getc the same, but the speed is slower than getc

10, int putc (int c, FILE * stream): shaping parameter c is converted into a char, and then write stream, while moving the file pointer to the next character

11, int putchar (int c): the same putc

12, int fputc (int c, FILE * stream): putc the same, but the speed is slower than putc

13, char * gets (char * s): read a line string from standard input stream (stdin), ending with "\ n", stored in the memory space pointed to by s, the successful return the memory address pointed to by s, failed to return NULL

14, char * fgets (char * s, int n, FILE * stream): read up to n-1 characters from the stream to the s memory space pointed

15, int puts (const char * s): s string pointed to "0" at the end of the string writes to the standard output stream stdout (not including "0")

16, int fputs (const char * s, FILE * stream): the string s to the file stream stream

17, size_t fread (void * ptr, size_t size, size_t nitems, FILE * stream): NITEMS read from the stream the data item to the memory pointed to by ptr, each data item is size bytes in size, a total reads nitems take the size characters

18, size_t fwrite (const void * ptr, size_t size, size_t nitems, FILE * stream): writes the data pointed to by ptr stream, the size of the write size of characters by NITEMS

Guess you like

Origin www.cnblogs.com/rao11/p/12120187.html