summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--c.html.markdown3
1 files changed, 2 insertions, 1 deletions
diff --git a/c.html.markdown b/c.html.markdown
index babf0954..92f07fe2 100644
--- a/c.html.markdown
+++ b/c.html.markdown
@@ -449,7 +449,8 @@ int main (int argc, char** argv)
int size = 10;
int *my_arr = malloc(sizeof(int) * size);
// Add an element to the array
- my_arr = realloc(my_arr, ++size);
+ size++;
+ my_arr = realloc(my_arr, sizeof(int) * size);
my_arr[10] = 5;
// Dereferencing memory that you haven't allocated gives