(C/C++)ÖµµÃÑо¿µÄһЩº¯Êý
1. memcpyº¯ÊýµÄʵÏÖ
Ê×ÏȶÔÕâ¸öº¯Êý×öһЩ˵Ã÷¡£
#include <string.h>
void *memcpy(void *to, const void *from, size_t count)
º¯Êýmemcpy()´ÓfromÖ¸ÏòµÄÊý×éÏòtoÖ¸ÏòµÄÊý×鸴ÖÆcount¸ö×Ö·û¡£Èç¹ûÁ½Êý×éÖصþ£¬²»¶¨Ò庯ÊýµÄÐÐΪ¡£
ÔÚC99ÖУ¬toºÍfromÓÉrestrictÐÞÊΡ£
ÏÈÀ´¿´¿´Î¢ÈíµÄʵÏÖ£º
void * __cdecl memcpy (
void * dst,
const void * src,
size_t count
)
{
void * ret = dst;
#if defined (_M_IA64)
{
extern void RtlMoveMemory( void *, const void *, size_t count );
RtlMoveMemory( dst, src, count );
}
#else /* defined (_M_IA64) */
/*
* copy from lower addresses to higher addresses
*/
while (count--) {
*(char *)dst = *(char *)src;
dst = (char *)dst + 1;
src = (char *)src + 1;
}
#endif /* defined (_M_IA64) */
return(ret);
}
ÔÙÀ´¿´¿´coreutilsÖеÄʵÏÖ£º
void *
memcpy (void *destaddr, void const *srcaddr, size_t len)
{
char *dest = destaddr;
char const *src = srcaddr;
while (len-- > 0)
*dest++ = *src++;
return destaddr;
}
ÔÙÀ´¿´LinuxÖÐʵÏÖ£º
void *memcpy(void *dest, const void *src, size_t count)
{
char *tmp = dest;
const char *s = src;
while (count--)
*tmp++ = *s++;
return dest;
}
¸÷ÖÖ¿¼ÂǵÄʵÏÖ
void* memcpy( void* dest, const void* src, size_t count )
{
if (count<0)
{
printf("Invalid count number !.\n");
return (void*)0;
}
if(src==NULL||dest==NULL)
return (void*)0 ;
if ((unsigned int)dest==(unsigned int)src)
{
printf("The source is equal with the destanation!.\n");
return dest;
}
char* d = (char*)dest;
const char* s = (const char*)src;
while(count--)
*d++ = *s++;
return dest;
}
¸ßÖÊÁ¿C++/C±à³ÌÖ¸ÄÏÀïÃæµÄʵÏÖ
void *memcpy(void *pvTo, const void *pvfrom, size_t size)
{
assert((pvTo != NULL) && (pvfrom != NULL)); // ʹÓöÏÑÔ
byte *pbTo = (byte *) pvTo; // ·ÀÖ¹¸Ä±äpvToµÄ
Ïà¹ØÎĵµ£º
ÕæÕý·¢ÏÖÈËÉúÐèҪ֪ʶµÄʱºò£¬ÎÒµÄÇà´ºÒѾÀË·ÑÁËÒ»°ë¡£
ÓÚÊǹÄÆðÓÂÆøÀ´µ½±±´óÇàÄñѧϰIT£¬¼øÓڶ෽¿¼ÂÇ£¬»¹ÊÇÑ¡ÔñÁËÈí¼þ²âÊÔ¡£
Èç½ñ¿ÎÒµµÄÒ»´ó°ëÒ²ÒѽáÊø£¬´Ó¸Õ¿ªÊ¼µÄÒ»ÎÞËùÖª£¬½¥½¥³É³¤ÎªÒ»¸ö²ËÄñ……
Ôڿγ̵Äѧϰ¹ý³ÌÖУ¬²Å½¥½¥·¢ÏÖ×Ô¼º¶ÔÓÚÕâ¸öÐÐÒµµÄÐËȤ£¬ÓÈÆäÊÇÈí¼þ¿ª·¢ÕâÒ»¿é¡£
ÉõÖÁ¶Ô×Ô¼ºÑ¡Ôñ×ö²â ......
http://www.cppblog.com/jacky2019/archive/2007/05/17/24269.html
c++ÖÐǶÈëpythonÈëÃÅ1
±¾ÈËÊÇÓÃvc2003+python2.5ѧϰµÄ£¬ÆäËüµÄÒ²Ó¦¸Ã²î²»Á˶àÉÙ
0. »µ¾³ÉèÖÃ
°ÑpythonµÄinclude/libsĿ¼·Ö±ð¼Óµ½vcµÄinclude/lib directoriesÖÐÈ¥¡£ÁíÍ⣬ÓÉÓÚpythonûÓÐÌṩdebug lib£¬ÌåµØ˵£¬¾ÍÊÇûÓÐÌṩpython25_d.libÁË¡£Äã¿É ......
×î½üÓиöÏîÄ¿ÐèÒªÔÚUNIXÏÂÓÃC×ö£¬ºÜ¾ÃûÓùýCÁË£¬·¢ÏÖЩÎÊÌâÈÝÒ׸ã´í¡£
Õâ¸öÎÊÌâºÜÈÝÒ׸ã´í£¬²¢µ¼ÖºܶàÎÊÌ⣬ÐèҪǿµ÷µÄÊÇfreadº¯Êý·µ»ØµÄ²¢²»ÊÇ×Ö½ÚÊý¡£
realRead = fread(buf,item,count,fp) £¨Ã¿´Î¶Áitem´óСµÄÊý¾Ý¿é£¬·Öcount´Î ......
Ò»¡¢¼ò½é
µ÷ÊÔÆ÷(±ÈÈçÏóGDB)ÄÜÈÃÄã¹Û²ìÁíÒ»¸ö³ÌÐòÔÚÖ´ÐÐʱµÄÄÚ²¿»î¶¯£¬»ò³ÌÐò³ö´íʱ·¢ÉúÁËʲô¡£GDBÖ÷ÒªÄÜΪÄã×öËļþÊÂ(°üÀ¨ÎªÁËÍê³ÉÕâЩʶø¸½¼ÓµÄ¹¦ÄÜ)£¬°ïÖúÄãÕÒ³ö³ÌÐòÖеĴíÎó¡£
* ÔËÐÐÄãµÄ³ÌÐò£¬ÉèÖÃËùÓеÄÄÜÓ°Ïì³ÌÐòÔËÐеĶ«Î÷¡ ......