Created
March 19, 2011 23:20
-
-
Save milesegan/877898 to your computer and use it in GitHub Desktop.
c99 variable-length array example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the old way: | |
int calculate_z(int a, int b) | |
{ | |
int *buffer = malloc(a * sizeof(int)); | |
// ... | |
free(buffer); | |
} | |
// the new way: | |
int calculate_z(int a, int b) | |
{ | |
int buffer[a]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment