memset in c code example
Example 1: memset c
#include
#include
int main () {
char str[50];
strcpy(str,"This is string.h library function");
puts(str);
memset(str,'$',7);
puts(str);
return(0);
}
Example 2: memset
/* memset example */
#include
#include
int main ()
{
char str[] = "almost every programmer should know memset!";
memset (str,'-',6);
puts (str);
return 0;
}
// Output:
// ------ every programmer should know memset!
Example 3: memset c
void *memset(void *str, int c, size_t n)
Example 4: memset c
This is string.h library function
$$$$$$$ string.h library function
Example 5: memset
// memset syntax
void * memset ( void * ptr, int value, size_t num );