Blogger Tips And Tricks|Latest Tips For Bloggers Free Backlinks
Showing posts with label C with memory function. Show all posts
Showing posts with label C with memory function. Show all posts

Monday, 19 November 2012

Write a program to memory set memset() function in C language examples?

memset(),memory set,memset() function, memory set function,memset() in C,memory set in C,program to memory set function,program to memset() function,Write a program to memory set memset() function in C language,memset() in c language


memset() function

              To set all bytes in a block to a particular value,by use memset() function.

     Syntax

               void *memset(void destination,int set_value,size_t count);

   Program

                   #include<stdio.h>
                    char a[100] = "God gift programming";
                   main()
                   {
                         memset(a+2,'*',10);
                  
                         printf("After memset : %s\n",a);

                    }

              Output
                            After memset :  Go**********gramming
        In this case,from a[2] position to 10 positions are overlapped with *.i.e. memset().

                           

Sunday, 18 November 2012

Write a program to memory move memmove() function in C language examples?

memmove(),memory move,memmove() function, memory move function,memmove() in C,memory move in C,program to memory move function,program to memmove() function,Write a program to memory move memmove() function in C language,memmove() in c language




 memmove() function

                   It copies the number of bytes from located pointed of source and it again copied into the located point of destination,In this case,the overlap will be occurring in the destination. i.e memmove() function.

syntax
              void *memmove(void *destination,void *source,size_t count);

 Program
            
                 #include<stdio.h>
                 main()
                 {
                       char str[] = "Programming";
             
                            memmove(str+1,str+3,4);

                     printf("After memory move  : %s\n",str);
                  }

    Output
                  After memory move :Pgramamaing

         Explanation 
                                 a[0]   1   2   3   4   5   6   7   8   9   10
                                   P     r    o   g    r    a   m  m   i   n     g
                    In memmove(str+1,str+3,4) function,from a[3] position to 4 bytes (a[6]) are copied and overlapped in destination string.So output is Pgramamaing. 

            

Saturday, 17 November 2012

Write a program to memory copy memcpy() function in C language examples?

memcpy(),memory copy,memcpy() function, memory copy function,memcpy() in C,memory copy in C,program to memory copy function,program to memcpy() function,Write a program to memory copy memcpy() function in C language,memcpy() in c language


 memcpy() function

      It copies the bytes of data between memory blocks or buffers.This function doesn't care about the
              type of data being copied.
                    It simply makes an exact byte for byte copy.

               Syntax:- 
                               void *memcpy(void *destination,void *source,size_t count);
  Program

                  #include<stdio.h>
                  #include<string.h>
                  main()
                  {
                        char str1[100] = "This is string";
                        char str2[100];

                          memcpy(str2,str1,14);

                        printf("str2 = %s\n",str2);
                  }

       Output:-
                        str2 = This is string

     If you will give the 10 at the count(14),it copies only 10 bytes.It gives the o/p is "This is st".