c++ error: array bound is not an integer constant before ']' token

    int h = 0;
    cout << "input an interge:";
    cin >> h;
    cout << h << endl;

    const int kl = h;
    char buf[kl];

    typedef struct tmpStru{    
        char field[kl];           // 即使在上面声明了 kl 为 const int,这边也是无法编译过去的
    }tmpStru;
 
 
 
 
 
 
posted @ 2022-03-14 13:42  halloowween  阅读(908)  评论(0)    收藏  举报