Comment on Tutorial - Using memset(), memcpy(), and memmove() in C By Emiley J



Comment Added by : Anderson Goulart

Comment Added at : 2010-08-24 19:15:14

Comment on Tutorial : Using memset(), memcpy(), and memmove() in C By Emiley J
To 15:
Sometimes it is useful to return the same address passed in the parameters and the developer should think what parameter he should return.
The common case occur when you want to chain the result of a function inside another function like: strcat(strcpy(buf, "hi "), "friend");
The strcpy function returns the same address of buf, as memcpy does. If strcpy did not return buf address, you should store this value elsewhere before use strcat.

Think of this another situation:
return memcpy(malloc(sizeof(int)), &number, 4)
You use malloc directly inside the memcpy function and has no source pointer stored in a variable. So, in this case, you would need the return value of memcpy.


View Tutorial



Ask a Question

Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. Hagti hain.. the complete program has been copy pa
View Tutorial          By: Macho Man at 2012-06-21 07:58:03

2. Bless you, bless you, bless you! You've kept me f
View Tutorial          By: KRuthenberg at 2009-09-25 19:42:55

3. lolz what's the code not working in JSP may be sen
View Tutorial          By: lolz at 2008-12-10 03:31:50

4. rms programe
View Tutorial          By: hardik at 2008-03-28 23:06:58

5. You are using stl; why do it by hand? All you nee
View Tutorial          By: gavin at 2013-02-21 12:31:29

6. It is really very good good notes of Public versus
View Tutorial          By: Nitin Gavande at 2011-07-16 08:47:56

7. dear sir, plz answer my following questions:

View Tutorial          By: hawa at 2012-01-29 08:29:39

8. Hi got an error while executing :

j

View Tutorial          By: Hi, at 2009-07-06 01:09:35

9. Thanks this page is very useful for me and now I k
View Tutorial          By: Yee Wai Wyne at 2009-10-18 23:03:41

10. Hi Kartikeyan and all,

can you plea

View Tutorial          By: Piyush at 2008-11-14 07:24:16