Learn Computer Science programming - C# and C++ Algorithms


String Copy (strcpy) implmentation

Copies the source string with the terminating null into the destination string. The destination string is assumed to have enough space.
File Size: 2609 kb
File Type: zip
Download File

#include <iostream>
#include <string.h>
#include <windows.h>
using namespace std;

void StringCopy (char *strDestination, char *strSource)
char *pd = &strDestination[0];
char *ps = &strSource[0];
while (*ps != '%%CONTENT%%')
*pd++ = *ps++;
*pd = '%%CONTENT%%';

void main()
int x;
wcout <<  endl << "*** String Copy ***" << endl;
wcout << "*************************************************" << endl;
char *Source = "Hello World!";
char Destination [13];
StringCopy (Destination, Source);
cout << "Destination array content copied to the new array is: " << Destination <<endl;
cin >> x;