【发布时间】:2019-10-16 15:45:05
【问题描述】:
我无法解决此警告
这是我的原型
int doubeInput (int* inputVal);
int squareInput (int* inputVal);
int cubeInput (int* inputVal);
有错误的行是
int (*funPtrArr[])(int)={doubleInput, squareInput, cubeInput};
这一行在main
while (choice >0 && choice <=3)
{
(*funPtrArr[choice])(inputVal);
}
这是我的功能
//function to perform the menu option 1,user input passed in
int doubleInput (int* inputVal)
{
//calculate double
int answer = (*inputVal) *= (2);
printf("%d x 2", inputVal);
return (answer);
}
//function to perform the menu option 2,user input passed in
int squareInput (int* inputVal)
{
//calculate square
int answer = (*inputVal) *= (*inputVal);
printf("%d x %d", inputVal, inputVal);
return (answer);
}
//function to perform the menu option 3,user input passed in
int cubeInput (int* inputVal)
{
//calculate cube
int answer = (*inputVal) *= (*inputVal) *= (*inputVal);
printf("%d ^ 3", inputVal);
return (answer);
}
我不断收到此错误,我对 C 很陌生。我的功能尚未完成,因为我无法测试它们。 请帮忙
【问题讨论】:
-
错字:
int doubeInput (int* inputVal);必须是doubleInput。
标签: c function pointers initialization function-pointers