Showing posts with label function program in c. Show all posts
Showing posts with label function program in c. Show all posts

Sunday, December 6, 2020

, ,

Example Program for memset function in c

 memset() function in C use to take a memory location and taken a VOID* pointer and this function copies the first n byte in memory location.

After update the memory location it return that location with the help of pointer.

Example Program for memset function in c
memset c

 

Syntax :  -

void* memset(void* mem_loc, int c, size_t n);

mem_loc is a memory location

c is an unsigned character in that upper syntax


Header File for memset function in c

Here this function deal with the characters so we have to use header file in the program

Now the complete import for memset function

#include <string.h>
 
void* memset(void* mem_loc, int c, size_t n);

Program Example for memset c

#include <stdio.h>
#include <string.h>
 
int main() {
    char a[] = {"Hello from functioninc"};
 
    printf("a = %s\n", a);
     
    printf("Filling the first 5 characters a with 'P' using memset\n");
     
    memset(a, 'P', 5 * sizeof(char));
     
    printf("After memset, a = %s\n", a);
 
    return 0;
}

Then the 5 character of the given string is filled by the 'P'

a = Hello from Functioninc
Filling the first 5 characters with 'P' using memset function in c
After memset c, a = PPPPP from Functioninc

Conclusion of memset c

Here we learn about the memset function in c and how to allocate the memory location.

Wednesday, October 21, 2020

, ,

List of function program in c programming language

 Well as all of you can see in previous tutorial of function in c programming we try to cover all in-build function in c not just only c but also other programming language like python, javascript, SQL, and other languages.

function program in c programming language
List of function program in c programming language

 

 

In this tutorial you can find all the function program in c and also learn about HOW TO USE IN-BUILD FUNCTION IN C with program example with explanation for these programs.

Check out our list of function program in c