另类的数组拷贝

来源:互联网 发布:壁虎数据恢复好用吗 编辑:程序博客网 时间:2024/04/29 21:37
void send(int *to,int *from,int count)
{
    
int n=(count+7)/8;
    
switch(count%8)
    {
        
case 7do { *to++=*from++;
        
case 6:         *to++=*from++;
        
case 5:         *to++=*from++;
        
case 4:         *to++=*from++;
        
case 3:         *to++=*from++;
        
case 2:         *to++=*from++;
        
case 1:         *to++=*from++;
        
case 0:         *to++=*from++;
                            }
while(--n>0);
    }
}

 

        这段代码在Gun c++和VC++里都编译通过了,它只不过是把from所指数组里的count个整数复制到由to指向的数组里。在第一次由switch判断后,流程交由do while控制,执行循环里的语句,而不在管case了。循环次数由n决定。

原创粉丝点击