What would you like to do?

What are the differences between strdup and strcpy functions used in C?

already exists.

Would you like to merge this question into it?

already exists as an alternate of this question.

Would you like to make it the primary and merge this question into it?

exists and is an alternate of .

strcpy - copy a string to a location YOU created (you create the location, make sure that the source string will have enough room there and afterwards use strcpy to copy) strdup - copy a string to a location that will be created by the function. The function will allocate space, make sure that your string will fit there and copy the string. Will return a pointer to the created area.
+ 9 others found this useful
Thanks for the feedback!

What are the differences between memcpy vs strcpy?

memcpy is general purpose copy. and strcpy is specific for string copying. strcpy will copy the source string to destination string and terminate it with '\\0' character but m

Write a function in 2 lines to copy one string to another without using strcpy?

There is almost nothing to explain if you know C Language. Here is the program:   #include void copyString(const char *src, char *dest); int main() { char str1[100

Difference Between strcpy and memcpy?

memcpy will copy NULL bytes also, but strcpy will stop copying if it encounters NULL Byte, since it consider NULL as a terminating character. cheers, som shekhar And anoth

What are the differences between Macros and Functions in C Language?

Macros are essentially shorthand representations of arbitrary sections of the source code, which makes the source code succinct, while its (the macro template's) expansion rep

What is the difference between actual and formal arguments used in functions in C language?

The arguments passed to the functions while the function is called is known as the actual arguments, whereas the arguments declared in the function header is called as formal

What is the difference between strcpy and strncpy in c language?

strcpy is meant to copy only null-terminated strings. It is probably implemented to copy every byte until it encounters a #0. strncpy() copies n bytes and it adds null termin

What is the difference between simple program and function in C?

  A function is a piece of code that has no or more arguments, that returns no or one value.   A program is code that implements the function int main(int argc, char**

How can use Strdup function in c language?

char* duplicated strdup("Hello World"); duplicated will now contain the address to dynamically allocated memory of a C-style string that contains "Hello World" and a null at

What is the difference between operator overloading and function overloading in C?

Function overloading is multiple definition with different signatures(the parameters should be different) for the same function. The parameter list have to be different in eac

What is the difference between main function in C java?

// C   int main(int argc, char** argv) {   return 0;   } // Java class MainClass {   public static void main(String[] args) { }   } Differenc

What is the difference between a function and class in C?

  Answer   A function is a set of instructions, whereas a class is a set of related data and its related functions. e-g an 'Add' function will have statements relat