Hey everyone,

I'm sure at the end it's just a stupid mistake, but I need some help at a something i'm writing on atm.

The idea is to add, subtract etc. fractions. I want to put the functions in a header and call them in the programm itself.

My problem is, that it doesnt recognize the functions i wrote in the .c of the module.

I'm a total beginner so pls no hate

The .h

Code:

#ifndef rational_h#define rational_h
#endif
typedef struct {
long numerator, denumerator;
}rational;
rational fraction1;
rational fraction2;
rational result;

The .c for the module

Code:

#include "rational.h"
rational addition(rational fraction1, rational fraction2,rational result)
{
result.numerator = fraction1.numerator + fraction2.numerator;
result.denumerator = fraction1.denumerator;
return result;
};
rational subtraction(rational fraction1, rational fraction2, rational result)
{
result.numerator = fraction1.numerator-fraction2.numerator;
result.denumerator = fraction1.denumerator;
return result;
};
rational multiplication(rational fraction1, rational fraction2, rational result)
{
result.numerator = fraction1.numerator * fraction2.numerator;
result.denumerator = fraction1.denumerator;
return result;
};
rational division(rational fraction1, rational fraction2, rational result)
{
long LMC;
result.numerator = fraction1.numerator * fraction2.denumerator;
result.denumerator = fraction1.denumerator*fraction2.numerator;
if (fraction1.denumerator < fraction2.denumerator)
{
LMC=ggT(fraction1.denumerator, fraction2.denumerator);
}
else
{
LMC = ggT(fraction2.denumerator, fraction1.denumerator);
}
result.numerator *= (LMC / result.denumerator);
result.denumerator = LMC;
return result;
};
long ggT(long a, long b)
{
static long helper = 0;
helper += b;
if (helper%a == 0 && helper%b == 0)
{
return helper;
}
else
{
return ggT(a, b);
}
}

The program itself (in between the functions im gonna add something for the output)

Code:

#include "rational.h"
int main(void)
{
addition(fraction1, fraction2);
subtraction(fraction1, fraction2);
division(fraction1, fraction2);
multiplication(fraction1, fraction2);
return 0;
}

Thanks everyone