title: C++ about dynamic array on stack
body: <p>So far as I know,C++/C doen't support dynamic array on stack .
  In the following delcaration :</p>
  
  <pre><code>int data[n] ; // if the n is not decided at compiling time ,this leads to error
  </code></pre>
  
  <p>But recently , I read some other guys code as following:</p>
  
  <pre><code>//**
  It seems the n number can not be decided at compling time,but when I run it , if i fprintf the formation, each time i got the correct array size !!!!!!
  the G++ version is 4.7.1 
  Is this because the G++ 4.7.1 support C++11 x which allow dynamic array?
   **//
  
  #include &lt;cstdio&gt;
  #include &lt;algorithm&gt;
  using namespace std;
  
  #include &lt;stdio.h&gt;
  
  char s[31];
  
  int Hash()
  {
      int sum=0;
      for(int i=0,k=0;k&lt;7;i++)
      {
          if(s[i]&gt;='0'&amp;&amp;s[i]&lt;='9')
          {
              sum*=10;k++;
              sum+=(s[i]-'0');
          }
          else if(s[i]&gt;='A'&amp;&amp;s[i]&lt;'Z')
          {
              sum*=10;k++;
              sum+=((s[i]-'A'-(s[i]&gt;'Q'))/3+2);
          }
      }
      return sum;
  }
  
  int main()
  {
  
      int n;scanf("%d",&amp;n);
      int data[n];getchar();
      //fprintf(stderr,"size is %d\n",sizeof(data)/sizeof(data[0]));
      //**
          It seems the n number can not be decided at compling time,but when I run it , if i fprintf the formation, each time i got the correct array size !!!!!!
       *//
      for(int tmp=0;tmp&lt;n;tmp++)
      {
          gets(s);
          data[tmp]=Hash();
      }
      sort(data,data+n);
      bool p=false;n--;
      for(int i=0,num=1;i&lt;n;i+=num=1)
      {
          while(data[i]==data[i+1])
          {
              num++;
              i++;
          }
          if(num&gt;1)
          {
              printf("%03d-%04d %d\n",data[i]/10000,data[i]%10000,num);
              p=true;
          }
      }
      if(!p)printf("No duplicates.\n");
      return 0;
  }
  </code></pre>