What value will be assigned to y ?
const int x = 5;
int main(int argc, char** argv)
{
    int x[x];
    int y = sizeof(x) / sizeof(int);
    return 0;
}
Explanation
In the example above, the int array size is evaluated before local x variable declaration is completed, hence, at the moment of x[] initialization, the global x is not hidden by the local one. Accordingly, sizeof(x) / sizeof(int) evaluates to 5 * sizeof(int) / sizeof(int), hence the result is 5.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты