Memory Operations in header file memory.h

Memory.h is the great source of memory fuction in C, well i have try to explain some of the important functions of memory.h file which are useful for memory managment & string handling, hope it will be helpful for you...

  • void *memchr (void *s, int c, size_t n) -- This memory funtion Search for a character in a buffer .
  • int memcmp (void *s1, void *s2, size_t n) -- this function Compare two buffers.
  • void *memcpy (void *dest, void *src, size_t n) -- this function Copy one buffer into another .
  • void *memmove (void *dest, void *src, size_t n) -- Move a number of bytes from one buffer lo another.
  • void *memset (void *s, int c, size_t n) -- Set all bytes of a buffer to a given character.
    Their use is fairly straightforward and not dissimilar to comparable string operations (except the exact length (n) of the operations must be specified as there is no natural termination here).
    Note that in all case to bytes of memory are copied.
  • The sizeof() function comes in handy again here, for example:
    char src[SIZE],dest[SIZE];int isrc[SIZE],idest[SIZE];
    memcpy(dest,src, SIZE); /* Copy chars (bytes) ok */
    memcpy(idest,isrc, SIZE*sizeof(int)); /* Copy arrays of ints */
    memmove() behaves in exactly the same way as memcpy() except that the source and destination locations may overlap.
  • memcmp() is similar to strcmp() except here unsigned bytes are compared and returns less than zero if s1 is less than s2 etc.

Related Links :

No comments:

Post a Comment

If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE

More Useful Topics...


History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming

My 1st Program...

void main ()
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();

Next Step...


void main ()
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();