I wanna add two variables.In my main program are 2 functions. I use Visual Studio 2013.There always appears the error C2660: 'function2': function does not accept arguments 1
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
double funktion1();
double funktion2();
int main()
{
double c;
{
c=funktion1();
funktion2(); //LINE 14
}
return 0;
}
double funktion1()
{
double a, b, c;
printf("Add two numbers!");
scanf_s("%lf%lf", &a, &b);
c = a + b;
return c;
}
double funktion2(double c)
{
printf("\n Result: %lf", c); //LINE 29
}
Thx for your help!
You use variable double c
in the statement printf
. At that point, you haven't assigned a value to c
. That is what the warning, or error in your case, is telling you.
Update:
When you need the return value of funktion1
in funktion2
, you must pass it as a parameter, e.g.
int main()
{
double c;
c = funktion1();
funktion2(c);
}
/* ... */
void funktion2(double c)
{
printf("\n Result: %lf", c); //LINE 29
}