(新手)从技术上讲,memset()和memcpy()函数有什么区别? [英] (newbie)Technically what's the difference between memset() andmemcpy() functions?
问题描述
(新手)从技术上说,memset()和
memcpy()函数之间的区别是什么?
< blockquote> sam写道:
(新手)从技术上说,memset()和
memcpy()函数之间的区别是什么?
你可以阅读手册......
memset()将内存区域设置为某个值
memcpy()将一个存储区复制到另一个区域
Bart
9月10日,8:59 * pm,sam< sameer ... @ gmail.comwrote:
(新手)从技术上说,memset()和
之间的区别是什么
memcpy()函数?
就像命名函数一样。
memset用于*设置*一系列内存到唯一价值。
#define BUFSIZE 1024
char buf [BUFSIZE];
memset(buf,0,sizeof(BUFSIZE) ); / *设置[buf,buf + BUFSIZE]范围
内存为0 * /
而memcpy用于*复制*一系列内存到另一个
范围内存。
char buf1 [BUFSIZE];
char buf2 [BUFSIZE] = {''a' ',''b'',''c''};
memcpy(buf1,buf2,sizeof(buf2)); / *将buf2的值复制到buf1
* /
Roadt
9月10日,下午2:59,sam< sameer ... @ gmail.comwrote:
(新手)从技术上说,memset()和<之间的区别是什么br />
memcpy()函数?
嗯,正式地说,他们做了不同的事情。实际上,谁b $ b关心谁?你永远不会在C ++程序中使用它们。
-
James Kanze(GABI软件)电子邮件:ja ******* **@gmail.com
Conseils eninformatiqueorientéeobjet/
Beratung in objektorientierter Datenverarbeitung
9placeSémard,78210 St.-Cyr- l''école,法国,+ 33(0)1 30 23 00 34
(newbie)Technically what''s the difference between memset() and
memcpy() functions?
sam wrote:(newbie)Technically what''s the difference between memset() and
memcpy() functions?You could read the manual ...
memset() sets a memory area to a certain value
memcpy() copies one memory area to another area
Bart
On Sep 10, 8:59*pm, sam <sameer...@gmail.comwrote:(newbie)Technically what''s the difference between memset() and
memcpy() functions?just as the naming of the funcation.
memset is used to *set* a range of memory to the unique value.
#define BUFSIZE 1024
char buf[BUFSIZE];
memset(buf, 0, sizeof(BUFSIZE)); /* set [buf, buf+BUFSIZE) range
memory to 0 */
whereas, memcpy is used to *copy* a range of memory into another
range of memory.
char buf1[BUFSIZE];
char buf2[BUFSIZE] = { ''a'', ''b'', ''c'' };
memcpy(buf1, buf2, sizeof(buf2)); /* copy the value of buf2 into buf1
*/
Roadt
On Sep 10, 2:59 pm, sam <sameer...@gmail.comwrote:(newbie)Technically what''s the difference between memset() and
memcpy() functions?Well, formally, they do different things. Practically, who
cares? You''d never use either in a C++ program.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l''école, France, +33 (0)1 30 23 00 34
这篇关于(新手)从技术上讲,memset()和memcpy()函数有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!