C Programming Language |
malloc |
calloc |
memset |
memcpy |
memory |
strcpy |
string |
strtok |
isalnum |
cctype |
errno |
cfenv |
clock |
difftime |
mktime |
ctime |
fprintf |
fscanf |
printf |
scanf |
stdio |
math |
Defined in string.h
void *memset( void *s, int c, size_t n);
The memset() function initializes the n bytes of the memory area pointed by s with to the str argument.
s : pointer to the block of memory to fill.
c : the value to set .
n : number of bytes to set.
#include <stdio.h>
#include <string.h>
int main ( int argc, char* argv[])
{
char s[50];
memset( s, 0, sizeof(s));
return EXIT_SUCCESS;
}
The above program, set the block of memory to 0 by using memset.
#include <stdio.h>
#include <string.h>
typedef struct myData
{
char str[50];
int i;
} MyData;
int main ( int argc, char* argv[])
{
MyData mMyData;
memset( &mMyData, 0, sizeof(MyData));
return EXIT_SUCCESS;
}
The above program, initializes the struct with memset.
zalloc is a third party library
posted on 2018-12-12 20:46:30 - C Programming Language Tutorials
posted on 2017-12-29 22:52:47 - C Programming Language Tutorials