The Code given below can be used in TURBO C++ Compilers: -
#include <iostream.h>
#include <string.h>
#include <conio.h>
void main()
{
clrscr();
char str1[30], str2[30];
// copying the string "Windows 11" to the str1
strcpy(str1, "Windows 11");
cout << "String 1: " << str1;
// copying the string "Windows 10" to the str2
strcpy(str2, "Windows 10");
cout << "\nString 2: " << str2;
// copying the value of str2 to the string str1
strcpy(str1, str2);
cout << "\nString 1: " << str1;
getch();
}
//........Coded by YASH ALAPURIA
The Code given below can be used in gcc/g++ Compilers: -
#include <iostream>
#include <stdlib.h>
#include <string.h>
using namespace std;
int main()
{
system("cls");
char str1[30], str2[30];
// copying the string "Windows 11" to the str1
strcpy(str1, "Windows 11");
cout << "String 1: " << str1;
// copying the string "Windows 10" to the str2
strcpy(str2, "Windows 10");
cout << "\nString 2: " << str2;
// copying the value of str2 to the string str1
strcpy(str1, str2);
cout << "\nString 1: " << str1;
return 0;
}
//........Coded by YASH ALAPURIA
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP