Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
C新手,我有这个功能:
void getNum(int *n) { scanf("%d", &n); }
主要是:
int main() { int someNum; getNum(&someNum); return 0; }
这个错误的'int **'部分究竟来自哪里,我如何传递东西还有其他问题吗?
唯一的问题是传递&n给 scanf:n已经是一个指针,因此您的scanf调用正在传递一个指向该指针的指针,因此会发出警告。
&n
n
scanf
利用:scanf("%d", n);
scanf("%d", n);