Home > Article > Backend Development > Can C Really Handle Variable Length Arrays?
Despite a common belief that variable length arrays are prohibited in C , the provided code demonstrates otherwise. How is this possible?
The C standard does not require compilers to support variable length arrays (VLAs). However, some compilers, such as GCC 4.7 and later, offer VLA support as an extension. The code in question utilizes this extension, which is why it successfully compiles and executes.
It's important to note that VLAs were initially slated for inclusion in C 14 but were ultimately excluded. They also did not make it into C 17. Therefore, VLA support remains an extension specific to certain compilers and is not a standard C feature.
The above is the detailed content of Can C Really Handle Variable Length Arrays?. For more information, please follow other related articles on the PHP Chinese website!