Write a program for concatenation of two strings


Default
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Write a program for concatenation two strings
// Ex: AimForJob, Success -> AimForJobSuccess

 
#include<string.h>
#include<stdio.h>
int main(){
    char str1[100],str2[100],output[200];
    printf("Enter first string:");
    gets(str1);
    printf("Enter second string:");
    gets(str2);
    int i=0,j=0;
    for(i=0;i<strlen(str1);i++){
        output[j++] = str1[i];                        
    }
    for(i=0;i<strlen(str2);i++){
        output[j++] = str2[i];                    
    }
    for(i=0;i<j;i++){
        printf("%c",output[i]);            
    }
    getch();
}

No comments:

Post a Comment