Creating an Array: Difference between revisions
Content added Content deleted
(→[[C]]: Removed syntax highlighting) |
|||
Line 52: | Line 52: | ||
'''Libraries:''' Standard |
'''Libraries:''' Standard |
||
Dynamic |
Dynamic |
||
⚫ | |||
<highlightSyntax language=C> |
|||
#include < |
#include <string.h> /* for memset */ |
||
int n = 10 * sizeof(int); |
|||
⚫ | |||
int |
int *myArray = (int*)malloc(n); |
||
if(myArray != NULL) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
myArray[ |
myArray[1] = 2; |
||
myArray |
free(myArray); |
||
myArray = NULL; |
|||
⚫ | |||
myArray = NULL; |
|||
⚫ | |||
</highlightSyntax> |
|||
Static |
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++]]== |