Link to home
Start Free TrialLog in
Avatar of dshrenik
dshrenikFlag for United States of America

asked on

Copy of a string

Please tell me how I can make a copy of a given string, at run time.

If my function takes char *str as a parameter, then I want make a local copy of str within the function.

Thanks!
Avatar of Peter Kwan
Peter Kwan
Flag of Hong Kong image

Avatar of dshrenik

ASKER

I don't want to use library functions.

Will it work if I find the length of the string, then dynamically allocate a char array and assign its value to the original?

If possible, please provide some sample code.

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Peter Kwan
Peter Kwan
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Deepu Abraham
Deepu Abraham
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial