New to C, I have this function:
void getNum(int *n) {
scanf("%d", &n);
}
And in main:
int main() {
int someNum;
getNum(&someNum);
return 0;
}
Where exactly does the ‘int **’ part of this error come from, and are there other issues with how I’m passing things around?
The only problem is passing
&nto scanf:nis already a pointer, and so yourscanfcall is passing a pointer to that pointer, hence the warning.Use:
scanf("%d", n);