函数_main中引用了未解析的外部符号_printf

时间:2016-02-15 10:52:49

标签: c

我是C编程的新手,我正在编写一个程序,它开始抛出以下错误:

  

错误LNK2019在function_main

中引用了未解析的外部symbol_printf

我正在使用C编译器。

我的代码如下所示:

#include <stdio.h>

int main(void)
{
    int EarthWeight;    // Weight on earth

    float Mercurypercent, Venuspercent,
    Marspercent, Jupiterpercent, Saturnpercent, Neptunepercent; // wieght percents

    float Mercurywieght, Venusweight, Marsweight, Jupiterweight, Saturnweight, Neptuneweight; // wieght outputs

    Mercurypercent = 0.378; // percent values of all the planets
    Venuspercent = 0.907;
    Marspercent = 0.377;
    Jupiterpercent = 2.36;
    Saturnpercent = 0.889;
    Neptunepercent = 1.12;  

    printf("what is the Weight of the person on earth? "); // Grabs the weight on earth
    scanf("%d", &EarthWeight);

    Mercurywieght = EarthWeight * Mercurypercent;
    Venusweight = EarthWeight * Venuspercent;
    Marsweight = EarthWeight * Marspercent;
    Jupiterweight = EarthWeight * Jupiterpercent;
    Saturnweight = EarthWeight * Saturnpercent;
    Neptuneweight = EarthWeight * Neptunepercent;

    Printf("Your Weight on Earth is: %d\n", EarthWeight);
    Printf("Your Weight on Mercury is: %f\n", Mercurywieght);
    Printf("Your Weight on Venus is: %f\n", Venusweight);
    Printf("Your Weight on Mars is: %f\n", Marsweight);
    Printf("Your Weight on Jupiter is: %f\n", Jupiterweight);
    Printf("Your Weight on Saturn is: %f\n", Saturnweight);
    Printf("Your Weight on Neptune is: %f\n", Neptuneweight);

    return 0;
}

1 个答案:

答案 0 :(得分:5)

C区分大小写,您正在调用Printf而不是printf

C也是非常错字敏感的,你的问题和变量名称中有一些,所以要小心......