Saturday 2 April 2016

String.h Library Function strcat how strcat works


STRCAT : This function takes two strings from user and concatenates the second one with the first here is the code how strcat works :
And Here Is the Code : >>>

#include <iostream>
#include <stdio.h>
using namespace std;

void strcat(char [],char [],char []);
int main()
{
    char arr[2000],arr1[2000],arr3[2000];
    cout<<"Enter Your First Statement : "<<endl;
    gets(arr);
    cout<<"Enter Your second Statement : "<<endl;
    gets(arr1);
    cout<<"After Concatenating : "<<endl;
    strcat(arr,arr1,arr3);
    return 0;
}
void strcat(char array1[],char array2[],char array3[])
{
    int i=0,j=0;
    while(array1[i]!='\0')
    {
array3[i] = array1[i];
i++;
    }
array3[i] = ' ';
i++;
    while(array2[j] != '\0')
{
array3[i] = array2[j];
i++;
j++;
}
array3[i] = '\0';
cout << array3;
}

No comments:

Post a Comment