Skip to content

Commit 95d9cd3

Browse files
committed
string concatenation with function without function c-basics
1 parent f7e478a commit 95d9cd3

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include<stdio.h>
2+
#include<string.h>
3+
void main()
4+
{
5+
char s[50],d[50],f[100];
6+
int i,j=0;
7+
printf("Enter string 1\n");
8+
gets(s);
9+
printf("Enter string 2\n");
10+
gets(d);
11+
12+
for(i=0;s[i]!='\0';i++)
13+
{
14+
f[j]=s[i];
15+
j++;
16+
}
17+
for(i=0;d[i]!='\0';i++)
18+
{
19+
f[j]=d[i];
20+
j++;
21+
}
22+
printf("String concatenation (without function) is ");
23+
for(i=0;i<j;i++)
24+
{
25+
printf("%c",f[i]);
26+
}
27+
printf("\n");
28+
strcat(s,d);
29+
printf("String concatenation (with function) is ");
30+
puts(s);
31+
}

0 commit comments

Comments
 (0)