#include <stdio.h>#include<memory.h>voidShowinta[][3]);//function DeclarationvoidMain () {inta[][3]={{ at, $, One},{ About, $, the},{ the, -, +},{ One, A, -}};//definition of a two-dimensional arrayShow (a);//a two-dimensional array as a formal parameter, traversing the displayMemset (A,0,sizeof(a));//0 operation for two-dimensional array, i.e. clear 0Show (a); }voidShowinta[][3]){ inti,j; for(i=0;i<4; i++){ for(j=0;j<3; j + +) {printf ("%d", A[i][j]); } printf ("\ n"); }}
Function: Sets the contents of each byte in a piece of memory pointed by S to the ASCII value specified by CH,
The size of the block is specified by the third parameter, which typically initializes the newly requested memory.
Usage: void *memset (void *s, char ch, unsigned n);
program Example:
#include <string.h>
#include <stdio.h>
#include <memory.h>
int main (void)
{
Char buffer[] = "Hello world/n";
printf ("Buffer before memset:%s/n", buffer);
memset (buffer, ' * ', strlen (buffer));
printf ("Buffer after memset:%s/n", buffer);
return 0;
}
Output Result:
Buffer before Memset:hello World
Buffer after Memset: ***********
In general, all modifications are made to the array, not to Cahr *s= "I am student" because
s points to a read-only memory, and you memset try to modify it, so the runtime to error, modify the method char *s modified to char s[]
C Language Memset Learning