answersLogoWhite

0

How can use Strdup function in c language?

Updated: 8/16/2019
User Avatar

Wiki User

8y ago

Best Answer

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 the end. Be sure to free duplicated when you're done with it or you'll have a memory leak.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can use Strdup function in c language?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Why you use 'integer' before function in C language?

To specify the return-type of the function.


What function is used to perform exponentiation in C language?

You can use the pow() function in math.h.


How do you allocate memory dynamically for a string of unknown size in c?

With function strdup (here is an implementation, if you don't have one already)char *strdup (const char *f){size_t len;char *to;len= strlen (f);to = malloc (len+1);if (to) memcpy (to, f, len+1);return to;}


Why you use else function in c language?

You cannot have a function named else, because it is a reserved word.


How you can convert from string to int in C language?

Use the atoi() or atol() function.


What is the use of gets function in c language?

Nothing, it is a security hole. Use 'fgets' instead.


What is the differnce between ordinary function and template function of c language?

The c language does not have template functions. That is a c++ thing.


Why you are using clrscr in c language?

Function 'clrscr' is not part of the C language. Or the standard libraries. It is MS-DOS specific function, use the help for details (clrscr means clear the screen).


Why use setcolor function in c graphics?

C language doesn't say anything about graphics, it is platform-dependent.


How do you use cosine in c language?

Include the header file math.h and use the function acos(d)


How do you createe a file using c language?

Use function open or creat or fopen.


How can you make a file in c language read only?

In UNIX: use function chmod