tailieunhanh - Linux programming unleash phần 3
Hacker Linux có mài dũa bộ phát triển dự án GNU luôn luôn phục vụ thành công cụ mạnh mẽ. New bộ widget đã diễn ra bên cạnh dự phòng UNIX cũ. Lesstif là một, thực hiện miễn phí tương thích với mã nguồn của Motif 1,2, KDE, máy tính để bàn K Môi trường dựa trên các thư viện lớp Qt từ Trolltech, câu trả lời thách thức máy tính để bàn | System Programming 170 Part II The line-oriented functions are inconsistent in their handling of newlines. The gets function is vulnerable to buffer overflows and should not be used use fgets instead but note the difference in newline handling. File Positioning The file positioning functions set the current position of a file they may not work on streams that do not point to normal files. The prototypes for these functions are listed below. include int fseek FILE stream long offset int whence long ftell FILE stream void rewind FILE stream int fgetpos FILE stream fpos_t pos int fsetpos FILE stream fpos_t pos The fseek function sets the position to offset. The whence parameter is SEEK_SET SEEK_CUR or SEEK_END these values determine whether the offset is relative to the beginning current position or the end of file. It returns the current position relative to the beginning or a value of -1 in the event of error check errno . The ftell function simply returns the current position. The rewind function sets the position to zero. The fgetpos and fsetpos functions are implemented as variations of ftell and fseek on other operating systems that do not treat all files as a simple stream of data bytes the fpos_t may be a structure instead of an integer. Buffer Control The prototypes for the buffer control functions are as follows. These functions provide for the three main types of stream buffering unbuffered line buffered and block buffered as well as the ability to flush any buffered but unwritten data out. include int fflush FILE stream int setbuf FILE stream char buf int setbuffer FILE stream char buf size_tsize int setlinebuf FILE stream int setvbuf FILE stream char buf int mode size_t size The fflush function flushes the buffers on output stream stream. The setvbuf function sets the buffer used by a stream. The arguments are the file pointer for the stream the address of the buffer to use the mode and the size of the buffer. The mode can be one of _IONBF
đang nạp các trang xem trước