Sunday, 27 March 2016

Memmove & Memcopy & Memset programs

Memcpy():-

               memcpy() function copies n bytes from memory area src to memory area dest. The memory areas may not overlap
 
Syntax:

            void *memcopy(void * destination, void *source, size_t count);
 
#include<stdio.h>
main()
{
   char str1[100]=”these is string”;
   char str2[100];
   memcpy(str2,str1,14);
   printf(“%s”,str2);
}

Memmove():-

               memmove() function copies n bytes from memory area src to memory area dest. The memory areas may overlap.
 
Syntax:

            void *memmove(void *destination,void *source,size_t count);
 
#include<stdio.h>
main()
{
  char str[]=”programming”;
  memmove(str+1,str+3,4);   out put=gramramming.
}

Memset():-

               memset() function fills the first n bytes of the memory area pointed to by s with the constant byte c.
 
Syntax:
              
             void *memset(void destination, int set_value,size_t count);
 
#include<stdio.h>
main()
{
    char arr[]=”god gift program”;
    memset(arr+2,*,10);
    printf(“%s”,arr);           output-->=go**********gram.
}


Memcmp():-

              memcmp() function compares the first n bytes of the memory areas s1 and s2. It returns an integer less than, equal to, or greater than zero if s1 is found, respectively, to be less than, to match,...

Syntax:-

                 int memcmp(const void *s1, const void *s2, size_t n);
 
-----------------------------------------------------------------------------------------
More details about C interview questions and programs: http://learnclanguage4.blogspot.com/

No comments:

Post a Comment

Structure

Defination :-                           Structure is a user defined data type. struct keyword is used to define a structure. Structur...