Strange C code - dynamic arrays?

后端 未结 4 501
说谎
说谎 2021-01-23 04:25

I have a bit of code copied from an unknown source:

 int Len=0;
 printf(\"Please input the length of vector\");
 scanf(\"%d\",&Len);
 float x[Len],y[Len],si         


        
4条回答
  •  一生所求
    2021-01-23 04:36

    This is called a Variable Length Array (VLA) and is a C99 feature.

    If your compiler does not recognise it on it's own then try switching C standards

    Try:

    --std=c99
    -std=c99
    --std=gnu99
    -std=gnu99
    

    The manual page of your compiler will be able to tell you the exact flag.

提交回复
热议问题