作者ckaha (★闪亮数学推理★)
看板EE_DSnP
标题[问题] C++的pointer丢给C function
时间Mon Jun 2 00:04:01 2008
as title
我在.c档
handle(unsigned* getInput,unsigned* numGate){
numGate[0] =1;
...
getInput = (unsigned*)malloc(sizeof(unsigned)*10);
getInput[0] =2;
...
}
.cpp
int main(){
...
unsigned *getInput;
unsigned numGate[3];
handle(getInput,numGate);
...
}
numGate 可以正确的拿到数值
可是 getInput却不行
是因为 malloc 挖出来的是在stack?
--
所说的话,必须是从未杀过人的人才有资格说,
未免流於太过天真的梦想。
但是,和事实比起来…我比较喜欢天真的梦想。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 125.225.151.232
1F:推 ric2k1:这个可能要回去复习一下 call-by-value & call-by-pointer 06/02 00:12
2F:→ ric2k1:的差别... 06/02 00:12
3F:→ ric2k1:还有, unsigned *n[3] 传给 unsigned* ? 06/02 00:12
4F:→ ckaha:阿 打错 没有* XD 06/02 00:35
※ 编辑: ckaha 来自: 125.225.151.232 (06/02 00:36)