一元'*'(具有'double')的无效类型参数是什么意思?

时间:2019-05-24 12:41:19

标签: function pointers void

我试图理解指针和void函数,我只学习了9周的C语言,而函数却让我有些头疼。关于为什么我在printf()调用指针* result

时出现此错误的解释非常棒
#include <stdio.h>
#include <math.h>

/*Declare remainder functions*/
double getRemainder1(double, double);
void getRemainder2(double, double, double *result);

int main()
{
    /*Declare variables*/
    double num1, num2, result;

    /*User input*/
    printf("Enter your two numbers (1-100)? ");
    scanf("%lf%lf", &num1, &num2);

    /* function call*/
    result = getRemainder1(num1,num2);

    printf("The remainder of %.2lf and %.2lf using the getRemainder1 function is %.2lf\n",num1, num2, result);
    printf("The remainder of %.2lf and %.2lf using void getRemainder2 function is %.2lf\n",num1, num2, *result);
    return 0;
}
void getRemainder2(double num1,double num2,double *result)
{
    *result = fmod(num1,num2);
    return;
}

double getRemainder1(double num1,double num2)
{
    double result;

    result = fmod(num1,num2);

    return result;
}

0 个答案:

没有答案