-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path19.cpp
More file actions
29 lines (25 loc) · 687 Bytes
/
Copy path19.cpp
File metadata and controls
29 lines (25 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<iostream>
#include<cstring> //for strcat() functionm
using namespace std;
int main()
{
//program to concatenate two strings
//1. using strcat function
char a[100] = "My username is ";
char b[] = "prakharjadaun";
strcat(a,b);
cout<<"After concatenation : \n"<<a<<endl;
//2. without strcat() function
char c[100]="Are you ";
char d[] = "mad!??";
//first calculate the length of the first char array
int len= strlen(c);
for(int j=0;d[j]!='\0';j++,++len)
{
c[len]=d[j];
}
//adding the null in the end
c[len]='\0';
cout<<"Without strcat() : "<<c<<endl;
return 0;
}