私は最初の言語としてC言語を学習しています。私は本が言うようにすべてをしました(Stephen G. Kochan:Programming in C、第3版)。 私は何が間違っていますか? 私はMicrosoft Visual Studio 2015を使用しています。C2106: '=':左側のオペランドはl-値でなければなりません
ありがとうございました! マーク
ここstruct date
{
int month;
int day;
int year;
};
int main(void)
{
struct date today, tomorrow;
int numberOfDays(struct date d);
printf("Adja meg a mai datumot (hh nn eeee): ");
scanf_s("%i%i%i", &today.month, &today.day, &today.year);
if (today.day != numberOfDays(today))
{
tomorrow.day = today.day + 1;
tomorrow.month = today.month;
tomorrow.year = today.year;
}
else if (today.month == 12)
{
tomorrow.day = 1;
tomorrow.month = 1;
tomorrow.year = today.year + 1;
}
else
{
tomorrow.day = 1;
tomorrow.month = today.month + 1;
tomorrow.year = today.year;
}
printf("A holnapi datum: %i/%i/%.2i.\n", tomorrow.month, tomorrow.day, tomorrow.year % 100);
return 0;
}
int numberOfDays(struct date d)
{
int days;
bool isLeapYear(struct date d);
const int daysPerMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if (isLeapYear(d) == true && d.month == 2)
days = 29;
else
days = daysPerMonth[d.month - 1];
return days;
}
bool isLeapYear(struct date d)
{
bool leapYearFlag;
if ((d.year % 4 == 0 && d.year % 100 = 0) || d.year % 400 == 00) //The error shows up here
leapYearFlag = true;
else
leapYearFlag = false;
return leapYearFlag;
}
最初に簡単なプログラムをお試しください。あなたが段階的にそれを構築するにつれ、あなたはあなたのエラーかより良い質問を発見するでしょう。 –
'd.year%100 = 0'は' d.year%100 == 0'である必要があります –
Kerrek:私はそうしました。これは本の第9章です。 Lashane:ありがとう!悲しいことに、このエラーは依然として発生します。 –