首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

更改二级指针所指内容?解决方案

2012-02-14 
更改二级指针所指内容??int*piNULLint**ppiNULLpi(int*)malloc(4)memset(pi,0,4)ppi(int**)malloc

更改二级指针所指内容??
int   *pi   =   NULL;
int   **ppi   =   NULL;

pi   =   (int*)malloc(4);
memset(pi,0,4);
ppi   =   (int**)malloc(4);
memset(ppi,(int)pi,4);   //所指内容置为pi值
**ppi   =   10;   //!!!挂掉

////////////////////////////
怎么修改可以赋给**ppi值

[解决办法]
void *memset( void *dest, int c, size_t count );

Return Value

memset returns the value of dest.

Parameters

dest

Pointer to destination

c

Character to set

count

Number of characters

Remarks

The memset function sets the first count bytes of dest to the character c.

故在此函数仅仅取了pi中的一个字节大小的内容,然后重复了4次,故指向不对了

热点排行