repositories
/
TD_C.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
0cd9f5d
)
exo1.c: Use VLA array correctly to store integer values and properly initialized it.
author
Jerome Benoit
<jerome.benoit@sap.com>
Sun, 26 Feb 2017 11:13:37 +0000
(12:13 +0100)
committer
Jerome Benoit
<jerome.benoit@sap.com>
Sun, 26 Feb 2017 11:13:37 +0000
(12:13 +0100)
Signed-off-by: Jerome Benoit <jerome.benoit@sap.com>
exo1/exo1.c
patch
|
blob
|
blame
|
history
diff --git
a/exo1/exo1.c
b/exo1/exo1.c
index 34251200207f6ef3afc6bc66f9f8e307ca55918f..eef51dbc61831d4219acab57f8b5e30604aa8f5b 100644
(file)
--- a/
exo1/exo1.c
+++ b/
exo1/exo1.c
@@
-54,8
+54,10
@@
void sortArray(int* array, int length) {
int main() {
int tab_length = 10;
- // GCC do not like variable sized array, even with the size variable properly initialized
- int tab[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ int tab[tab_length];
+ for (int i = 0; i < tab_length; i++) {
+ tab[i] = 0;
+ }
for (int i = 0; i < tab_length; i++) {
printf("Enter integer value at array's index[%d]? ", i);