Copy String C++

Problem

Write a C++ function to copy an existing string. Do not use built in functions.

Solution

This is a straight forward question and to my surprise I was asked this question in a site interview. If you are not prepared you might stumble on the easy ones. The idea is to allocate memory for the new string then copy characters one by one from source to destination.

Code

Here is the code in C++

Tags:

Add a Comment

Your email address will not be published. Required fields are marked *