我不知道如何解决的C代码错误

时间:2019-12-03 14:34:53

标签: c++ error-handling

我得到了一个我不理解并知道如何解决的错误... 我已经下载了calendar.h并将其放在头文件中,而我已经下载了calendar.c并将其放在源文件中。

#include <iostream>
#include <stdlib.h>
#include "calendar.h"


int getYearFromUser(void);
int getMonthFromUser(void);



int main(void) {
    system("chcp 1252");

    int year, month;
    year = getYearFromUser();
    month = getMonthFromUser();


    printCalendarMonth(month, year);

    return 0;
}


int getYearFromUser(void) {

    int year = 1;
    printf("Year (later than 1900): ");
    scanf_s("%d", &year);
    printf("\n\n");

    return year;
}

int getMonthFromUser(void) {

    int month = 0;
    printf("Month (between 1 and 12): "); 
    scanf_s("%d", &month);
    printf("\n\n");

    return month;
}

我得到的错误是:

严重性代码描述项目文件行抑制状态 错误LNK2019无法解析的外部符号“ _main

中引用的“ void __cdecl printCalendarMonth(int,int)”(?printCalendarMonth @@ YAXHH @ Z)

printCalendarMonth(month,year);在calendar.c中看起来像这样

void printCalendarMonth(int month, int year)
{
    int weekday, mDays;
    printf("\n\n %s %d\n", monthName(month), year);
    printf(" Sö Må Ti On To Fr Lö\n");
    mDays = monthDays(month, year);
    weekday = firstDayOfMonth(month, year);
    indentFirstLine(weekday);
    for (int day = 1; day <= mDays; day++)
    {
        printf(" %2d", day);
        if (weekday == SATURDAY)
            printf("\n");
        weekday = ++weekday % 7;
    }
    if (weekday == SUNDAY)
        printf("\n");
}

0 个答案:

没有答案