小编Web*_*btm的帖子

需要在clang中使用-lm和pow(),但不能在sqrt()中使用

在FreeBSD上10.1使用Clang版本3.4.1

现在我已经看到其他线程询问如何使用pow()进行编译,但我还没有看到有这个问题的线程.举个例子:

#include <math.h>
#include <stdio.h>

int main()
{
  float result;
  result = pow(2,3);
  printf("%d", result);
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

现在使用pow(),我需要发出clang参数-lm.

cc -lm -o name name.c

但是,更换pow(2,3)sqrt(5);,我可以编译cc -o name name.c.如果它们都使用math.h,那么为什么pow()需要链接到库?方面没有:安装gcc进行测试,我根本不需要使用-lm.

c clang

4
推荐指数
1
解决办法
639
查看次数

对于带指针和终止空值的循环

char charArray[10];
char* pArray = charArray;
for(int i = 0; i < 10; i++)
{
*pArray = '\0';
pArray++;
}
Run Code Online (Sandbox Code Playgroud)

从这个片段开始,*pArray ='\ 0'是什么?意思?我不明白这.

c++ null

-7
推荐指数
2
解决办法
164
查看次数

标签 统计

c ×1

c++ ×1

clang ×1

null ×1