に二重になります機能:それも実行されませんこれは前に私が持っていたコードである分数
char fractionCalculator(long double interest)
{
char multiples_of_one_eighth[7] = { 1/8, 1/4, 3/8, 1/2, 5/8, 3/4, 7/8 };
char Return;
char * returnValue;
if (interest - trunc(interest) < 0.0625)
{
Return = '\0';
}
else if (interest - trunc(interest) < 0.1875)
{
Return = multiples_of_one_eighth[1];
}
else if (interest - trunc(interest) < 0.3125)
{
Return = multiples_of_one_eighth[2];
}
else if (interest - trunc(interest) < 0.4375)
{
Return = multiples_of_one_eighth[3];
}
else if (interest - trunc(interest) < 0.5625)
{
Return = multiples_of_one_eighth[4];
}
else if (interest - trunc(interest) < 0.6875)
{
Return = multiples_of_one_eighth[1];
}
else if (interest - trunc(interest) < 0.8125)
{
Return = multiples_of_one_eighth[1];
}
}
。私が作ったとき、その部分が文字列として表示されなければならないと思っていましたが、私はそれがひどく間違っていたと推測しています。私はそれが実行されない理由は、関数の出力と入力と関係があると思いますか?私はこれで何時間も働いていて、まだそれを理解することはできません。助けることができる誰にも感謝します!
「混合番号」とはどういう意味ですか?これはCで有効なデータ型ではありません.'1/8 'のような値は、 'char'に意味を果たすことができると思いますか? – abelenky
「混合番号」とは何ですか?そして、「走っていない」とはどういう意味ですか?正確な行動は何ですか? [mcve]を入力し、入力、予想される出力/動作、実際の出力/動作を含めてください。 – kaylum
警告をオンにします。ほとんどのコンパイラは '-Wall'です。それは多くの問題を指摘するでしょう。 – Schwern