Блог пользователя tamojit9

Автор tamojit9, 13 лет назад, По-английски
#include<iostream>
using namespace std;
main()
{
      int m;
      cin>>m;
      int re[m];
      cout<<sizeof(re);
}

This code is running perfectly in codeforces GNU C++ 4.7. But why?? shouldn't the array size be a constant.

  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится

»
13 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Latest GCC versions seem to be able to cope with that. I was shocked as well the first time my friend claimed this is possible in GCC. I agree that it is quite misleading for beginners, because it, kind of, "violates" basic principles of "what's good and what's wrong" :)

Here is mentioned what to do if you need to have that warning. http://stackoverflow.com/questions/17899274/g-variable-size-array-no-warning