29 Aug 16:09
strange memcpy example
From: Jens Guether <guether <at> hhi.de>
Subject: strange memcpy example
Newsgroups: gmane.comp.lib.boost.devel
Date: 2008-08-29 14:11:47 GMT
Subject: strange memcpy example
Newsgroups: gmane.comp.lib.boost.devel
Date: 2008-08-29 14:11:47 GMT
Hi all together, I found a very strange example of the memcpy() function on the web page: http://www.boost.org/community/generic_programming.html ---------------------------------------------------------- void* memcpy(void* region1, const void* region2, size_t n) { const char* first = (const char*)region2; const char* last = ((const char*)region2) + n; char* result = (char*)region1; while (first != last) *result++ = *first++; return result; } ---------------------------------------------------------- Perhaps I missed something essential, but usually the memcpy() function returns a pointer to the destination (region1 in this case). The above version of memcpy() returns region1+n. regards Jens ---- Visit us at IFA 2008 / Berlin (Germany), 29 August - 3 September 2008 / Hall 5.3 Booth 17(Continue reading)
RSS Feed