#include"string.h"
紅花崗ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!
#include"stdio.h"
intmain(void)
{
inti,j;
inta[2][3]={{1,2,3},{4,5,6}};
intb[2][3];
memcpy(b[0][0],a[0][0],24);
printf("%d",b[1][0]);
}
擴展資料
#includestdio.h
#includestring.h
#includestdlib.h
voidprintarr2d(int(*a)[3],introw,intcol);
intmain()
{
inti,j;
inta[2][3]={{1,2,3},{4,5,6}};
intb[4][3]={{0,0,0},{0,0,0}};
memcpy(b[2],a,sizeof(int)*2*3);
printarr2d(b,4,3);
return0;
}
/***********************************************
打印顯示數(shù)組
************************************************/
voidprintarr2d(int(*a)[3],introw,intcol)
{
inti,j;
for(i=0;irow;i++)
{
for(j=0;jcol;j++)
{
printf("%d",a[i][j]);
}
printf("\n");
}
}
C++ 復(fù)制函數(shù)
一、場景一:全部默認
#include
class base
{
public:
base()
{
}
base(int dt):
data(dt){
}
void get()
{
printf("base::data = %d\n",data);
}
public:
int data;
};
class derived:public base
{
public:
derived()
{
}
derived(int dt,int ddt):
base(dt),ddata(ddt)
{
}
void get()
{
base::get();
printf("derived::ddata = %d\n",ddata);
}
private:
int ddata;
};
int main()
{
derived da(1,5);
derived db(2,10);
da.get();
db.get();
da = db;
da.get();
db.get();
derived dc(da);
dc.get();
base ba(da);
ba.get();
getchar();
}
場景二、基類默認,派生類自定義
#include
class base
{
public:
base()
{
}
base(int dt):
data(dt)
{
}
void get()
{
printf("base::data = %d\n",data);
}
public:
int data;
};
class derived:
public base
{
public:
derived()
{
}
derived(int dt,int ddt)
:base(dt),ddata(ddt)
{
}
derived(const derivedd)
{
printf("call derived::copy construct function.\n");
ddata = d.ddata;
}
derived operator=(const derivedd)
{
printf("call derived::operator= function.\n");
ddata = d.ddata;
return *this;
}
void get()
{
base::get();
printf("derived::ddata = %d\n",ddata);
}
private:
int ddata;
};
場景三、基類自定義,派生類默認
#include
class base
{
public:
base()
{
}
base(int dt):
data(dt)
{
}
base(const baseb)
{
printf("call base::copy construct function.\n");
data = b.data;
}
base operator=(const based)
{
printf("call base::operator= function.\n");
data = d.data;
return *this;
}
void get()
{
printf("base::data = %d\n",data);
}
public:
int data;
};
class derived:public base
{
public:
derived()
{
}
derived(int dt,int ddt):
base(dt),ddata(ddt)
{
}
void get()
{
base::get();
printf("derived::ddata = %d\n",ddata);
}
private:
int ddata;
};
場景四、基類派生類都自定義
#include
class base
{
public:
base()
{
}
base(int dt):
data(dt)
{
}
base(const baseb)
{
printf("call base::copy construct function.\n");
data = b.data;
}
base operator=(const based)
{
printf("call base::operator= function.\n");
data = d.data;
return *this;
}
void get()
{
printf("base::data = %d\n",data);
}
public:
int data;
};
class derived:public base
{
public:
derived()
{
}
derived(int dt,int ddt):
base(dt),
ddata(ddt)
{
}
derived(const derivedd):base(d)
{
printf("call derived::copy construct function.\n");
ddata = d.ddata;
}
derived operator=(const derivedd)
{
printf("call derived::operator= function.\n");
ddata = d.ddata;
return *this;
}
void get()
{
base::get();
printf("derived::ddata = %d\n",ddata);
}
private:
int ddata;
};
strcpy(t[i],a[j],n);該語句的意思是:將某已知二維數(shù)組a的第j行前n個字符復(fù)制到另一個二維數(shù)組t的第i行中。給分吧
#include?stdio.h
#includestring.h
int?main()
{
char?ch[40];
char?c[20]={"asdfgh"};
strcpy(ch,c);
printf("%s\n",ch);
}