我想編寫一個程序,增加了兩個有理數與結構 這是代碼型形式參數1不完整
#include <stdio.h>
#include <stdlib.h>
struct Fraction{
int numerator ;
int denominator ;
};
int mainMenu(void);
struct Fraction readStructure(void); /*this works well*/
struct Fraction add(struct Fractoin num1, struct Fraction num2);/*this doesn't*/
int main()
{
struct Fraction num1 = readStructure();
struct Fraction num2 = readStructure();
struct Fraction result = add(num1, num2) ;
return 0 ;
}
struct Fraction readStructure(void)
{
struct Fraction temp;
printf("-> Enter the numerator : ");
scanf("%d", &temp.numerator);
printf("-> Enter the denominator : ");
scanf("%d", &temp.denominator);
while(temp.denominator == 0)
{
printf("--> Zero in the denominator isn't possible.. try again : ");
scanf("%d", &temp.denominator);
}
return temp ;
}
struct Fraction add(struct Fractoin num1, struct Fraction num2)
{
struct Fraction temp;
temp.numerator = (num1.numerator * num2.denominator) +
(num2.numerator * num1.denominator);
temp.denominator = num1.denominator * num2.denominator ;
return temp ;
}
編譯器說,這是錯誤的,給了我這些錯誤+一些更警告..
error: type of formal parameter 1 is incomplete.
error: parameter 1 ('num1') has incomplete type.
:D OMG,我根本沒有注意到! 非常感謝 – SaNtoRiaN
這也在兩個地方 –
@iharob是的當然,我會,但9分鐘後,像這個網站說:) – SaNtoRiaN