Commit 254c24df authored by STEFF Laurent's avatar STEFF Laurent
Browse files

corrected array on heap

parent a07a686b
......@@ -140,10 +140,8 @@
"metadata": {},
"outputs": [],
"source": [
"{\n",
" const unsigned int Ndigit = 5; // not known at compile-time!\n",
" \n",
" int* pi_first_five_digits = new int[Ndigit];\n",
"void create_array(unsigned int ndigit) { \n",
" int* pi_first_five_digits = new int[ndigit];\n",
" \n",
" pi_first_five_digits[0] = 3;\n",
" pi_first_five_digits[1] = 1;\n",
......@@ -152,7 +150,12 @@
" pi_first_five_digits[4] = 5;\n",
" \n",
" delete[] pi_first_five_digits;\n",
"}"
"}\n",
"\n",
"// let's say that 5 comes from a size of an input file, or\n",
"// whatever defined at runtime (vs compile time)\n",
"// we would call then:\n",
"create_array(5);"
]
},
{
......@@ -254,4 +257,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment