c - 下面的宏使用有什么问题?

标签 c syntax macros compiler-errors

isPowerof(2)main()导致预期);错误 ...这有什么问题?

#include<stdio.h>

#define isPowerof2(n)  (!(n & (n-1))

int main(){
    int n,p;
    clrscr();
    printf("\nEnter the number to be Checked:");
    scanf("%d",&n);
    isPowerof2(n);
    printf("%d",p);

getch();
}

最佳答案

您还缺少一个括号:

#define isPowerof2(n)  (!(n & (n-1)))
                                    ^

旁注:如果您不必使用宏,请改用函数。

关于c - 下面的宏使用有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19230179/

相关文章:

C 计算一串数字中出现次数最多的数字

c - 是否可以 typedef 预处理器指令?

jQuery(基本语法问题): modifying several parameters with one . css

ios - Xcode 8 和预处理器宏

objective-c - C 函数与 Objective-C 方法?

c - 如何实际检测 musl libc?

syntax - Rust 是否有等同于 Python 的列表理解语法?

php - Python 的 None 单例在 PHP 中的等价物是什么?

iphone - 似乎无法有条件地为 iPhone/Mac 进行编译

c - 如何在 C 中使用迭代器宏来防止阴影