Concatenation of string C Example Program
Concatenation of string Definition:
In computer programming, string concatenation is the operation of joining two character strings end-to-end.
Concatenation of string Explanation:
For example, the strings "snow" and "ball" may be concatenated to give "snowball".
For example, the following expression uses the "+" symbol as the concatenation operator to join two strings: "Hello, " + "World";, and has the value "Hello, World".
Example Concatenation of string Program:
/* Example Program For Concatenation of string In C Programming Language
little drops @ thiyagaraaj.com
Coded By:THIYAGARAAJ MP */
// Header Files
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
char string1[20];
char string2[20];
char string[100];
clrscr();
printf("Enter Sring1: ");
scanf("%s",string1);
printf("Enter Sring2: ");
scanf("%s",string2);
for(i=0;string1[i]!='\0';i++)
string[i]=string1[i];
string[i]=' ';
for(j=0;string2[j]!='\0';j++)
string[i+j+1]=string2[j];
string[i+j+1]=' ';
printf("%s",string);
getch();
}
Sample Output:
Enter Sring1: Hello,
Enter Sring2: World
The Concatenated string is: Hello, World
Read More Articles
- Use of getch(),getche() and getchar() in C
- Switch Case Statement Example Program In C Programming Language
- C Character Set
- Convert a Floating-point value to an Integer in C
- Data Input and Output gets and puts Example Program In C
- Special Operators In C
- Pointer Representation and Pointer Example Programs
- C Data Input and Data Output
- Simple While Loop Example Program In C Programming Language
- Data Output printf and putchar Example Program In C
- C Introduction
- C Operators
- Storage Classes In C
- C Pointers
- File Management
- C Identifiers
- Loop Control Statements
- Hello World - Simple C Program
- C Array
- Single Character Output Function : putchar()
- C Reserve Words
- C Specific Properties and Implementation
- If else Statement Example Program In C Programming Language
- If Statement Example Program In C Programming Language
- Confusing Array in C ( Array Representation and Initialization )