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:
d442d0f
)
TP 8 exo1: be more explicit about the malloc size.
author
Jérôme Benoit
<jerome.benoit@piment-noir.org>
Mon, 27 Feb 2017 18:24:46 +0000
(19:24 +0100)
committer
Jérôme Benoit
<jerome.benoit@piment-noir.org>
Mon, 27 Feb 2017 18:24:46 +0000
(19:24 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
TP_8/exo1/exo1.c
patch
|
blob
|
blame
|
history
diff --git
a/TP_8/exo1/exo1.c
b/TP_8/exo1/exo1.c
index b10155c712d93fb3ee033ca8ef2bc6202ab49523..beea2f689f02cc43e785b4eb3077f2bcd6de5f79 100644
(file)
--- a/
TP_8/exo1/exo1.c
+++ b/
TP_8/exo1/exo1.c
@@
-11,14
+11,15
@@
int main() {
int* arr;
printf("Longeur?\n");
int size = promptValue();
- arr = malloc(sizeof(arr[size]));
+ //arr = malloc(sizeof(arr[size]));
+ arr = malloc(sizeof(int)*size);
for (int i = 0; i < size; i++) {
printf("Valeur?\n");
arr[i] = promptValue();
}
- printf("Sortie\n");
+ printf("Sortie
:
\n");
int sum = 0;
for (int i = 0; i < size; i++) {
printf("%d (%d)\n", arr[i], sum += arr[i]);