What does the *memcpy in

Code:
char *memcpy(char*dest,char*orig,int n)

mean?

The function is supposed to copy n characters from the origin array and paste them in the destiny array.
I know that the char means that the function returns char and that the *array is the same as array[].

So does this mean that the function returns an array with an indefinite number of char-type elements?
First of all the definition of memcpy appears to be wrong see http://www.cplusplus.com/reference/cstring/memcpy/ notice the void instead of char.
Also the asterisk signifies that it is a pointer. If you asking this because you could not google an asterisk because it is a special character and now you believe you have a situation where you cannot learn about what the asterisk does because you don't know what to call it you can google C asterisk and you will find out that it is a pointer. I had to do this a long time ago when I learned about ternary statements. I just searched for C question mark and it turned out that many people already had the same question.
Alright thanks. I still haven't learnt about pointers, I will learn more and then get back to this.
To clarify somewhat, the grammar for a function prototype is something like this:
Code:
rtype name([type name],*);
In this case, the return type (rtype) is char*. C's pointer sigil can be somewhat confusing at times, since it often appears to be tied to a name rather than a type.

Quote:
So does this mean that the function returns an array with an indefinite number of char-type elements?
You could kind of look at it that way, yeah. Without outside knowledge of what the returned pointer points to, you can't make any decision on what sorts of accesses are valid. In the case of memcpy, it returns the same value as the first parameter.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement