setsockopt
设置套接字选项第二个参数level是被设置的选项的级别,如果想要在套接字级别上设置选项,就必须把level设置为 SOL_SOCKET。
int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen);
memset
设置对象内存void *memset(void *s, int ch, size_t n);
作用
En
Copies the value static_cast<unsigned char>
(ch) into each of the first count characters of the object pointed to by dest. If the object is a potentially-overlapping subobject or is not TriviallyCopyable (e.g., scalar, C-compatible struct, or an array of trivially copyable type), the behavior is undefined. If count is greater than the size of the object pointed to by dest, the behavior is undefined.
Ch
将ch的值复制到dest指向的对象的前count个字符中。如果对象是潜在重叠的子对象或不是TriviallyCopyable(例如,标量,C兼容的结构或平凡可复制的类型的数组),则行为是未定义的。如果count大于dest指向的对象的大小,则行为是未定义的。
复制ch的值到 s 指向的对象的前 n 个字符中。
void *memset(void *s, int ch, size_t n);
返回一个指向内存块 s 的指针。
snprintf
函数En Writes formatted data from variable argument list to sized buffer. Ch 将格式化的数据从变量参数列表写入大小缓冲区。
int snprintf( char *buffer, size_t buf_size, const char *format, ... );//可变参数
memcpy
拷贝对象内存En
Copies count bytes from the object pointed to by src to the object pointed to by dest.
Both objects are reinterpreted as arrays of unsigned char.
If the objects overlap, the behavior is undefined.
If either dest or src is a potentially-overlapping subobject
(e.g., a field in a C-compatible struct) or is not TriviallyCopyable
(e.g., scalar, C-compatible struct, or an array thereof),
the behavior is undefined. If count is zero, the function does nothing.
Ch
将src指向的对象的count个字节复制到dest指向的对象。
两个对象都被重新解释为无符号字符数组。
如果对象重叠,则行为是未定义的。
如果dest或src是潜在重叠的子对象(例如,C兼容结构中的字段)
或不是TriviallyCopyable(例如,标量,C兼容结构或其数组),
则行为是未定义的。如果count为零,则函数不执行任何操作。
void *memcpy(void *dest, const void *src, size_t count);
void *memcpy(void *dest, const void *src, size_t count)
{
char *d = dest;
const char *s = src;
while (count--)
*d++ = *s++;
return dest;
}
fread
读取文件En
Reads an array of count elements,
each one with a size of size bytes,
from the stream and stores them in the block of memory specified by ptr. Ch
从流中读取一个大小为size字节的count个元素的数组,并将它们存储在ptr指定的内存块中。
size_t fread(void *ptr, size_t size, size_t count, FILE *stream);
fseek
移动文件指针En
Sets the position indicator associated with the stream to a new position.
The end-of-file internal indicator of the stream is cleared after a successful call to this function,
and all effects from previous calls to ungetc on this stream are dropped.
Ch
将与流关联的位置指示器设置为新位置。
成功调用此函数后,流的文件结束内部指示器将被清除,并且此流上先前调用ungetc的所有效果都将被丢弃。
int fseek(FILE *stream, long int offset, int whence);
ungetc
函数的效果fseek
函数的效果fsetpos
函数的效果rewind
函数的效果