Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

initialize array in c with 0

static char ZEROARRAY[1024]; // if declaration is in global scope or is static it will alredy be initialized to Zeroes
// OR
char ZEROARRAY[1024] = {0}; // Compiler fills unwritten entries with zeroes
// OR
memset(ZEROARRAY, 0, 1024); // Alternatively you could use memset to initialize the array at program startup:
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #initialize #array
ADD COMMENT
Topic
Name
7+9 =