Monday, February 25, 2013

C Language Example # 25 Example : Join two string without function


C Language Example # 25 Example : Concatenate the String at String 1 with the use of Logic.

* Concatenate two string without function..
* Combine two string without function.
* Join two string without function.

//Written by Latest Technology Guide    
//Title : C Language Example # 25 Example : Concatenate the String at Str 1 with the use of Logic.


#include <stdio.h>
#include <conio.h>
# include <string.h>

void main()
{
clrscr();
char str1[20]={"This is My "}, str2[20];
int i=0,j=0;

printf("Enter String 2 :");
gets(str2);

printf("\nConcatenate the String at Str 1 with the use of Logic\n\n");

while(1)
{
if(str1[i]!=NULL)
{
i=i+1;
continue;
}

str1[i]=str2[j];
i=i+1;
j=j+1;

if(str2[j]==NULL)
break;
}
str1[i]=NULL;
printf("String 1 is \n\n");
puts(str1);

printf("\n Concatenate with the use of function strcat()");
strcat(str1,str2);
printf("\n Content of Str 1 :");
puts(str1);

getch();
}

Output:

* Program will join two string without using function.

--------------------------------------------------------------------------------
Explanation of C Programming Language Example # 25 Example : Concatenate the String at String 1 with the use of Logic.

* Enter Your String 1
* Enter Sting 2.
* Program will display concatenate of two string.

Note: All programs are developed and tested using Turbo C++ 3.0 under Windows XP. We just want to provide guidelines to the users. If you are using any other Compiler or other operating system they you need to modify this program as per your requirements. 

No comments:

Post a Comment