-1

我在 C 中使用 Code::Blocks 和 C 代码并且有一些错误..

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

#define SQRT(num)    \
((num>0)    ?\
(sqrt(num)): \
(printf("the number is negative")))

int main() {
    printf("The file %s is executeD \n", _FILE_);
    printf("the sqrt of number %d is %f \n",8,SQRT(8));
    printf("the sqrt of number %d is %f \n",9,SQRT(9));
    printf("the sqrt of number %d is %f \n",-9,SQRT(-9));

    return 0;
}       
4

3 回答 3

7

它是__FILE__,不是_FILE_

于 2012-05-05T11:29:24.310 回答
1

宏是__FILE__(每边双下划线)

于 2012-05-05T11:29:33.023 回答
1

尝试使用双下划线,例如:__FILE__

于 2012-05-05T11:29:47.357 回答