Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?



Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When shoul..

Answer / Ambesh Hemkar

"The strcpy() function copies a string from the source to a destination, including the null character (). In contrast, memcpy() is used for copying arbitrary blocks of memory. Strcpy() converts the source string into a character array (char*), while memcpy() operates on raw memory (void*). They should be used depending on whether you are dealing with strings or generic data."

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

#include<std.h> int main() { char *str[]={"Frogs","Do","Not","Die","They","Croak!"}; printf("%d %d\n",sizeof(str),strlen(str)); ...return 0; } what will the output of the above program?

6 Answers  


What are nested functions in c?

1 Answers  


How many header files are in c?

1 Answers  


By using C language input a date into it and if it is right?

1 Answers   Aricent,


please help me.. how to write a code of this output?? "Enter range number:"10 1 is an odd number 2 is an even numbers 3 in an odd numbers 4 " to 10" "printing all odd numbers:" 1,3,5,7,9 "printing all even numbers:" 2,4,6,8,10 "sum of all odd numbers:25 "sum of all even numbers:30 using a C Programming ARRAY pleas pleas help.. its my project ..please :(

1 Answers  


Explain the properties of union.

1 Answers  


how to swap two nubers by using a function with pointers?

1 Answers  


Why c is faster than c++?

1 Answers  


which header file contains main() function in c?

17 Answers   Google, HCL, TCS,


char p="data"; printf(p);

2 Answers  


how can be easily placed in TCS.

0 Answers   TCS,


What are the types of arrays in c?

1 Answers  


Categories