Thread: memcpy function

  1. #1
    Registered User
    Join Date
    Sep 2011
    Location
    Athens , Greece
    Posts
    357

    memcpy function

    I have a query about memcpy's prototype.

    Since the arguments are restricted pointers and according to a restricted pointer only that pointer has access to the object how the function works? and copies the bytes from one pointer to another?

    I think overlapping situation is something like :

    Code:
    #include<stdio.h>
    
    int main(void)
    {
      char msg[60]="abcdefghijklmnopqrstuvwxyz";
     char tmp[60];
    
    strcpy(tmp , msg);
    memcpy(tmp+4 , tmp+16 , 10); /* without overlap temp is : abcdqrstuvwxyzopqrstuvwxyz */
    
    strcpy(tmp,msg);
    memcpy(tmp+6, tmp+4,10); /* with overlap temp is :
    abcdefefefefefefqrstuvwyz */
    
    return 0;
    }
    I am confused when I see the keyword restrict in the function although I know its concept.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    This thread appears to have been superseded by The keyword restrict in the prototype of memcpy function.

    *thread closed*
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory Overlap and memcpy function.
    By Mr.Lnx in forum C Programming
    Replies: 5
    Last Post: 07-21-2013, 03:10 PM
  2. memcpy
    By ueg1990 in forum C Programming
    Replies: 3
    Last Post: 07-05-2012, 04:39 AM
  3. memcpy
    By sharp_wan in forum C Programming
    Replies: 19
    Last Post: 10-03-2011, 04:16 PM
  4. Replies: 2
    Last Post: 03-11-2009, 07:52 AM
  5. Help: About memcpy()
    By naruto in forum C Programming
    Replies: 41
    Last Post: 06-25-2004, 03:47 PM