sqrt() function not working with variable arguments [duplicate]
问题 This question already has an answer here: Why am I getting “undefined reference to sqrt” error even though I include math.h header? [duplicate] 5 answers I don't know if I'm missing something obvious, but it appears that I'm unable to compute square roots of a variable in C; the sqrt() function only seems to work on constants. This is my code: #include <math.h> #include <stdio.h> int main() { double a = 2.0; double b = sqrt(a); printf("%f", b); return 0; } When I run this program, I get the