面试
hfyinsdu
烂笔头--好记性不如烂笔头
展开
-
C function implementation: memcpy and strcpy and others
An often being asked interview question. The key is to handle address overlap. void *memcpys(void *dest, const void *src, size_t n) { int i, l; void *dst; char *d, *s; d = dest; ...原创 2020-02-27 16:17:35 · 79 阅读 · 0 评论 -
程序输出
1. copy from blog main() { int a[5]={1,2,3,4,5}; int *ptr=(int *)(&a+1); printf("%d,%d",*(a+1),*(ptr-1)); } 输出:2,5 *(a+1)就是a[1],*(ptr-1)就是a[4],执行结果是2,5 &a+1不是首地址+1,系统会认为加一个a数组的偏移...转载 2020-03-28 16:05:12 · 320 阅读 · 0 评论