c - Visual Studio 2012 中的 #include <math.h>

标签 c visual-studio-2010 visual-studio visual-studio-2012 math.h

这是我编写的程序:

#include "stdafx.h"
#include "math.h"


int main ()
{
    int phi;
    float c;
    scanf_s("%d",&phi);
    c=(pow(sin(phi)*cos(phi),-2))-(pow(tan(phi),2)+pow(tan(phi),-2));
    if (c==2)
    {
        printf("C is 2,Don't Worry \n");
    }
    else
    {
        printf("Be Careful,C is not 2,How is this possible ?! \n");
    }
}

问题是 Visual Studio 无法识别 sincostanpow。 我究竟做错了什么 ? (如您所见,语言是 C!)

最佳答案

尽管您没有指出错误消息,但最可能的答案是您需要明确告诉编译器您希望将代码视为 C 源文件而不是 C++ 源文件。 Visual Studio 没有“按原样”用于 C 控制台应用程序的项目模板,但您可以手动添加源文件。只需确保其扩展名为 .c 而不是 .cpp

关于c - Visual Studio 2012 中的 #include <math.h>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26743107/

相关文章:

asp.net-mvc - WebDeploy 发布不上传 PDB 文件(MVC 预编译 webapp,VS2013)

c++ - 托管 DirectX 作为起点

c++ - 我如何保持打开控制台?

c - 用指针更新 C 中的数组

.net - VS 2015移动文件后无法运行发布

c++ - #pragma hdrstop

javascript - 为带有 XML 注释的类实例启用 Javascript Intellisense

c - 我应该如何开始用 C 或 C++ 编写 FCFS 调度程序?

c - 当我试图在代码块编译器中运行这个程序时,strstr() 函数每次都返回 0。为什么?

Javascript:使用 ActiveXobject 保存文件