Creating an Array: Difference between revisions
Content added Content deleted
(-> Tcl; also fixed formatting for VBscript) |
(→[[C]]: Added syntax highlighting) |
||
Line 51: | Line 51: | ||
'''Libraries:''' Standard |
'''Libraries:''' Standard |
||
Dynamic |
|||
<highlightSyntax language=C> |
|||
⚫ | |||
#include <stdlib.h> /* for malloc */ |
|||
⚫ | |||
int n = 10 * sizeof(int); |
|||
int n = 10 * sizeof(int); |
|||
int *myArray = (int*)malloc(n); |
|||
⚫ | |||
{ |
|||
{ |
|||
memset(myArray, 0, n); |
|||
⚫ | |||
myArray[0] = 1; |
|||
myArray[1] = 2; |
|||
free(myArray); |
|||
free(myArray); |
|||
myArray = NULL; |
|||
} |
|||
} |
|||
</highlightSyntax> |
|||
Static |
|||
<highlightSyntax language=C> |
|||
int myArray2[10] = { 1, 2, 0}; /* 3..9 := 0 */ |
int myArray2[10] = { 1, 2, 0}; /* 3..9 := 0 */ |
||
</highlightSyntax> |
|||
==[[C plus plus|C++]]== |
==[[C plus plus|C++]]== |