我理解如何pow()正确使用我只是想知道为什么当我运行这个代码ans= inf.
我很难理解这一点.
这是否与chars有关,只能采用-128到+127的值并pow()计算方式?
这与" %c"我的第一个scanf参数中的空间有什么关系吗?
Linux 4.9.0-7-amd64 debian 4.9.110-1 gcc版本6.3.020170516
#include <stdio.h>
#include <math.h>
int main ()
{
char base, exp;
float ans;
printf("Enter base number : ");
scanf(" %c", &base);
printf("Enter exp number : ");
scanf(" %c", &exp);
ans = pow(base,exp);
printf("%c raised to the %c power equals %f", base, exp, ans);
return 0;
}
Run Code Online (Sandbox Code Playgroud)