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 */
Dynamic
<highlightSyntax language=C>
#include <stdlib.h> /* for malloc */
#include <string.h> /* for memset */
#include <stdlib.h> /* for malloc */
#include <string.h> /* for memset */
int n = 10 * sizeof(int);
int *myArray = (int*)malloc(n);
int n = 10 * sizeof(int);
if(myArray != NULL)
int *myArray = (int*)malloc(n);
if(myArray != NULL)
{
{
memset(myArray, 0, n);
memset(myArray, 0, n);
myArray[0] = 1;
myArray[1] = 2;
myArray[0] = 1;
myArray[1] = 2;
free(myArray);
myArray = NULL;
free(myArray);
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++]]==