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. where's your main sir?
View Tutorial          By: armor at 2010-12-08 01:00:45

2. class Abc
{
public void display()
View Tutorial          By: Umapathi REddy at 2012-05-23 09:54:29

3. i connect my program to my sql and create table. a
View Tutorial          By: Santosh Agrawal at 2013-04-08 13:00:56

4. Everything is running.... But it doesn't send....
View Tutorial          By: Amirtharaj at 2009-04-14 05:26:26

5. could you plz tell me how to run this all programs
View Tutorial          By: abhishek at 2010-10-27 00:08:57

6. Excellent. I want you to publish about memory allo
View Tutorial          By: Mohamed firnaz at 2011-12-07 04:54:27

7. It's a good article.Would you please elaborate th
View Tutorial          By: Chandra at 2015-10-05 12:24:24

8. Simple and easy code..........
View Tutorial          By: mandalson at 2011-12-24 04:08:12

9. The example program was very easy to understand un
View Tutorial          By: vijay at 2011-12-27 07:34:35

10. Please send me the multithreading chat application
View Tutorial          By: Vaibhav at 2010-06-23 23:58:43