Some commonly used functions: memset, memcpy, strlen, strcpy

memset is generally used as an initialization function. The function is to set all the contents of a certain memory to a certain value.
Format: start pointer, set initial value, length

memset(buffer,0,sizeof(int)*10);//在buffer处初始化10个0

memcpy is used to copy several bytes from the start of the source memory address to the target memory address.
Format: return pointer, source pointer, length

memcpy(dst, src, strlen(src)+1);

strlen is a function to calculate the length of a string. The number of characters from any location in the memory to'\0' is generally 1 less than that obtained by sizeof.
Format: String pointer

strlen(str);

strcpy is a string copy function, which copies the string containing the'\0' terminator to another address space.
Format: return pointer, source pointer

strcpy(dst,src);

Guess you like

Origin blog.csdn.net/weixin_42979679/article/details/103846996