Prototype: extern void *memset (void *buffer, int c, int count);
Function: Sets the first count bytes of the memory area indicated by buffer to character C.
Contains header files:<string.h>
Note that this function is a string function, so be sure to include the string header file.
How to use:
int A[50];
memset (A,0,sizeof (a));
That way, all the values in array A are assigned to 0, and sizeof is a unary operator that gets the byte size of array A.
It is also important to note that the Memset function is populated by byte bytes, so A is generally char * type . For other types of a, the values that can be populated are two, 0, and -1. Since the computer uses twos complement to denote numbers, the 0 and twos complement are full 0,-1 's twos complement of 1.
The memset is a byte-by-byte setting that sets each byte of an int to 1, which is 0x01010101, and the decimal is 16843009.
What do I do to initialize 1?
To set the int array to 1, use the For loop to set the line. Or enumerations can also be
Why can't memset initialize array elements to 1?