C++ program to copy one string into another string without using strcpy.
C++ program to copy string without using strcpy
#include <iostream> using namespace std; int main(){ char source[1000], copy[1000]; int index = 0; cout << "Enter a string" << endl; cin.getline(source, 1000); // Copy String while(source[index] != '\0'){ copy[index] = source[index]; index++; } copy[index] = '\0'; cout << "Input String: " << source << endl; cout << "Copy String: " << copy; return 0; }Output
Enter a string APPLE Input String: APPLE Copy String: APPLE
Recommended Posts