Can you please explain the difference between strcpy() and memcpy() function?



Can you please explain the difference between strcpy() and memcpy() function?..

Answer / Lalit Kumar Verma

"strcpy() copies a string (null-terminated array of characters) from one location to another, while ensuring that the destination is allocated enough space to hold the entire source string. It automatically adds a null character at the end. memmove() or memcpy(), on the other hand, can copy a block of memory with any size and does not guarantee null termination of the copied data."

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

You have an array of n integers, randomly ordered with value 1 to n-1.The array is such that there is only one and one value occurred twice. How will you find this number?

1 Answers  


Is fortran still used in 2018?

1 Answers  


what is the use of operator ^ in C ? and how it works?

2 Answers  


What is %d used for?

1 Answers  


Taking an example,differentiate b/w loader and linker ?

1 Answers  


how to go with this?

1 Answers   Wipro,


what is difference between ++(*p) and (*p)++

17 Answers   Accenture, HCL, IBM,


Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

1 Answers  


How can I implement sets or arrays of bits?

0 Answers  


which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +

1 Answers  


b) 4 c) 6 d) 7 32. Any C program a) must contain at least one function b) need not contain ant function c) needs input data d) none of the above 33. Using goto inside for loop is equivalent to using a) continue b) break c) return d)none of the above 34. The program fragment int a=5, b=2; printf(“%d”,a+++++b); a) prints 7 b)prints 8 c) prints 9 d)none of the above 35. printf(“ab” , “cd”,”ef”); prints a) ab abcdef c) abcdef, followed by garbage value d) none of the above 36. Consider the following program segment. i=6720; j=4; while((i%j)==0) { i=i/j; j=j+1; } On termination j will have the value a) 4 b) 8 c) 9 d) 6720

1 Answers   HCL,


Create a registration form application by taking the details like username, address, phone number, email with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 3 users and display the details. While taking input password must appear as “****”.

1 Answers  


Categories