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



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. Hi there, what a nice example, very useful for me
View Tutorial          By: Yanny at 2009-12-10 12:34:26

2. Performance is low while working with BULK DATA
View Tutorial          By: kailash at 2009-07-17 06:11:55

3. From the last 2 year. i'm working on hibernate fra
View Tutorial          By: nick at 2011-01-03 02:11:48

4. sir please check the program in for loop
View Tutorial          By: vc ramreddy at 2009-09-28 23:35:10

5. Hi, If any body was able to send the message suces
View Tutorial          By: Pradeep Singh Chouhan at 2011-03-02 23:03:05

6. Java is very interesting,I wish to do certificate
View Tutorial          By: Dzunisani Chauke at 2012-11-05 10:19:35

7. Thanks....
View Tutorial          By: A.V. Bajaj at 2012-06-02 09:40:16

8. sample program exception handling
View Tutorial          By: priya at 2009-09-10 05:40:29

9. The code for CharArrayReader is not working. So, w
View Tutorial          By: Maya Joshi at 2012-06-23 14:30:26

10. Quite Helpful.....
^_^

View Tutorial          By: Alfred_Septio at 2012-09-26 12:38:47