c - 错误 C2057 : expected constant expression in vs2008

标签 c

static const unsigned int x[] = { 1, 2, 3, 5 };  
static const int q = sizeof(x) **/** sizeof(x[0]);  

size_t fun(int n, int m)  
{  
    unsigned int p[q];  
}

如何解决这个错误?这是一个c代码。

最佳答案

这是什么 **/** sizeof(x[0]); ,这不是如何发表评论,并且不要忘记在末尾添加分号表达。

static const unsigned int x[] = { 1, 2, 3, 5 };  

static const int q = sizeof(x)/sizeof(x[0]); /* sizeof(x[0]); */

size_t fun(int n, int m)  
{  
    unsigned int p[q];  
}

int main()
{
}

关于c - 错误 C2057 : expected constant expression in vs2008,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33144746/

相关文章:

c - STM32F0 UART 不工作

检查reg中安装的应用程序路径

c++ - 一个接受输入小写字母的短程序,它给出大写字母并在按下回车键时退出

c - 链表给出相同的结果 C

c - 如何从文本文件中读取格式化行并将信息保存在链表中? IN C

c - 使用 strcmp 和 char *arr[] 的段错误

c - Wav 文件多次写入和播放

c - 如何使用 sysfs kobject 作为全局变量?

c - 强制套接字函数创建一个旧的 id

crtexe.c - 关于在 VSCode 中调试 C/C++ 文件的问题