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 all, i have tried above code, but am getting fo
View Tutorial          By: swathi at 2010-06-24 05:18:28

2. Can you please tell me what software to be install
View Tutorial          By: Heena Yeole at 2015-03-10 18:05:18

3. Exception in thread "main" java.lang.NoC
View Tutorial          By: RobustTm at 2008-12-18 23:19:46

4. Thanks a lot Ramlak! This is still very useful af
View Tutorial          By: Jacky at 2009-08-08 23:49:12

5. i have a program in which we have to find the summ
View Tutorial          By: Navjyot at 2013-01-28 10:38:55

6. Hi Ashish, You just have to create an object of SM
View Tutorial          By: Ramlak at 2007-03-13 09:22:51

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

8. This all works fine, but when I read records from
View Tutorial          By: Ayac at 2011-10-31 10:58:21

9. how to create inode address using c++
View Tutorial          By: pooja at 2014-06-24 05:50:33

10. Helpful..........

Good

View Tutorial          By: Ravi at 2009-07-03 07:08:56