In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "what is the use of memcpy function in C language", the content is easy to understand, clear, hope to help you solve doubts, the following let Xiaobian lead you to study and learn "what is the use of memcpy function in C language" this article.
Memcpy
Function: memory copy
Function prototype:
Void * memcpy (void * dest, const void * src, size_t count)
Use:
Format: memcpy (destination, original, memory size you want to manipulate (in bytes))
Copy the "Parameter 3" byte content starting from "Parameter 2" to "Parameter 1"
The memecpy function is similar to strncpy.
Example:
# include # include # include int main () {int aa [] = {1pr 2pc 3P 4}; int bb [10] = {0}; memcpy (bb, aa, 4 * sizeof (int)); / / copy the contents of 4 bytes (each int type is 4 bytes) in the aa array to the bb array for (int I = 0; I)
< 10; i++) //打印bb数组全部数据 { printf("%d ", bb[i]); } } 最后bb字符串中前4*4个字节的内容被改为aa的内容Note: memcpy cannot copy overlapping memory.
# include # include # include int main () {int aa [] = {1, 2, 7, 8, 9, 10}; my_memcpy (aa + 2, aa, 24); for (int I = 0; I < 10; iBex +) {printf ("% d", aa [I]);}}
Output:
This problem occurs when copying overlapping memory.
These are all the contents of the article "what is the use of memcpy functions in C language". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.