我有一个功能如下:
void foo (int *check){
*check= 9;
printf("*check: %d\n",*check);
//when I print "*check" here, the value changes as 9.
}
这是主要功能。
void main () {
int check=5;
foo(&check);
printf("check: %d\n",check);
//when I print "check", gives me 5.
}
我想更改“检查”变量的值,但它不起作用。我在哪里犯错?谢谢!
我在运行时使用makefile。编辑: malloc 已被删除,现在它给了我 Segmentation fault (core dumped) 错误