#include "stdio.h"#include <memory.h>void main(){int a[3][3]={{20,25,18},{15,26,9},{34,14,27}};int temp[3];int k,t;memcpy(temp,a[1],3);memcpy(a[1],a[0],3);memcpy(a[0],temp,3);for(k=0;k<3;k++){for(t=0;t<3;t++)printf(" %d ",a[k][t]);printf("\n");}}我想把數(shù)組a中a[3][3]={{20,25,18},{15,26,9},{34,14,27}};前兩行元素調(diào)換,即輸出15 26 920 25 1834 14 27可是結(jié)果卻是15 25 1820 26 934 14 27只有每行的第一個元素被調(diào)換了位置,為什么不是整體調(diào)換?。?
以下代碼內(nèi)容為關(guān)于memcpy()函數(shù)的使用
白板的微信
2022-03-20 13:09:12