Difference between strdup and strcpy?



Difference between strdup and strcpy?..

Answer / Kuldeep Garg

strcpy() is a C library function that copies the string pointed by src, including the terminating null character, into the array pointed by dest. It assumes that the destination array has enough space to store the source string plus one for the null character. On the other hand, strdup() returns a new string which is a duplicate of the original string pointed by src. It dynamically allocates memory for the new string and returns a pointer to it.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

Explain the difference between using macro and inline functions?

1 Answers  


What are proxy objects in c++?

1 Answers  


What does new in c++ do?

1 Answers  


What is the difference between set and map in c++?

1 Answers  


What is difference between class and structure in c++?

1 Answers  


Define anonymous class.

1 Answers  


Is it possible to write a c++ template to check for a function's existence?

1 Answers  


Any one help me plzzzz..... i have an assignment...... that is ______*********_______ Write a program that takes an equation as a string and does the following: Solve 8 parts to achieve 100% 1 - 5 are compulsory. Input: 2x^2+3x+4=0 1) read a quadratic equation 2) print its coefficients (coefficients range is 0 to 9) 3) print the solution of the equation 4) tackle imaginary solution e.g. ( (2+3i), (2-3i) ) 5) allow spaces within the input 6) after solving one equation; ask for an other, terminate on empty line. * 7) tackle negative values as well * 8) tackle more than one values of same exponent (e.g. 2x^2 + 3x^2 + 4x + 3 = 0)* 9) use strtok * 10) print the solution in fractions e.g. 1.5 should be printed as (1)1/2 * 11) coefficient can be greater than 9** 12) values on both sides of the ‘=’ sign** 13) plot the graph of the polynomial** 14) use a compiler other than Borland** 15) submit before May 25, 2009 11:59 PM ** _______******________ plz send me c++ code at sweety.alvi@gmail.com

1 Answers  


What do you understand by zombie objects in c++?

1 Answers  


Explain what are single and multiple inheritances in c++?

1 Answers  


What is function prototyping?

1 Answers  


How much is c++ certification?

1 Answers  


Categories