Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
239 views

C Program To Concatenate Two Strings Using Strcat Function

write a c program to concatenate Two Strings using Strcat, write a c program for concatenation of Two Strings using Strcat function, write a c program to concatenate Strings using Strcat function, write a c program for concatenation of Strings using Strcat function, write a c program to concatenate n Strings using Strcat function, write a c program for concatenation of n Strings using Strcat function, concatenation of Strings using c program, concatenation of Strings using c programming, concatenation of Strings using c code,c code for concatenation of Strings using strcat,
Copyright
© © All Rights Reserved
0% found this document useful (0 votes)
239 views

C Program To Concatenate Two Strings Using Strcat Function

write a c program to concatenate Two Strings using Strcat, write a c program for concatenation of Two Strings using Strcat function, write a c program to concatenate Strings using Strcat function, write a c program for concatenation of Strings using Strcat function, write a c program to concatenate n Strings using Strcat function, write a c program for concatenation of n Strings using Strcat function, concatenation of Strings using c program, concatenation of Strings using c programming, concatenation of Strings using c code,c code for concatenation of Strings using strcat,
Copyright
© © All Rights Reserved
You are on page 1/ 6

c program to concatenate two

strings using strcat function


The word concatenate means is to combine or append two strings. For example there
are two strings twenty and two, the concatenation of these two strings is twentytwo.
There are three methods to concatenate strings. We can write a c program to
concatenate strings using strcat, using pointers and using arrays.
strcat Function: strcat string function is used to concatenate two strings. strcat is
available under string.h file. The function takes two strings as inputs or parameters
and output a string which is concatenation of two strings and save in first string.
syntax: strcat( string str1 string str2)

contributed by:

www.programmingsimplysolved.com

write a c program to concatenate two


strings using strcat function
write a c program to concatenate two strings using strcat function / write a C
program for concatenation of two strings in array

#include<stdio.h>
#include<conio.h>
// string.h contains built in string functions
#include<string.h>
void main()
{
char str1[30], str2[30];
int i:
printf(“.. c program to concatenate two strings using strcat function…”)
printf(“Enter first string “);
gets(str1);
printf(“Enter next string to concatenate “);
gets(str2);
strcat(str1, str2); //concatenates str1 & str2 and saves in str1
printf(“concatenation of two strings using strcat is %s\n”,str1);
getch();
}
OUTPUT:

.. c program to concatenate two strings using strcat function …

Enter first string


one

Enter next string to concatenate


two

concatenation of two strings using strcat is


onetwo

----------------------------------------------------
Other programs:
c programs on storage classes

Static variable scope


Register variable scope
External variable scope
Automatic variable scope

number logics

amicable or not
Prime number or not
Perfect number or not
Palindrome number or not

Convert decimal number to octal


Convert decimal number to hexadecimal
Converting decimal number to binary

Calculate simple interest


Calculating compound interest

matrices

Add sparce matrices


Add two matrices

files

Copy one file to other

strings

Palindrome string or not


Reverse string using arrays
Reversing string using strRev
Reverse string using pointers
String length using strLen
String length using pointers
Replace characters in string
substring or not using arrays
First occurrence of character in string
Last occurrence of character in string
Convert string to uppercase using strupr
Converting string to lowercase using strlwr
Convert string to lowercase using arrays, pointers
Concatenate strings using strcat
Concatenation of strings using pointers
Concatenate strings using arrays
Compare two strings using arrays

other c programs

Generate Employee payslips


Count students scoring marks>50%

-----------------------------------------------------------------------------------------------

write a c program to concatenate strings using


strcat
write a c program to concatenate strings using strcat function / write a C program for
concatenation of strings in array

#include<stdio.h>
#include<conio.h>
// string.h contains built in string functions
#include<string.h>
void main()
{
char str[30], str2[30];
int i:
printf(“..To concatenate ten strings usind strcat…”)
printf(“Enter first string “);
gets(str1);
for( i=1;i<10;i++)
//you can set n intead of 10 for multiple strings
{
printf(“Enter next string to concatenate “);
gets(str2); // To concatenate a space add strCat( str1, ” “); next to this
strcat(str1, str2); //concatenates str1 & str2 and saves in str1
}
printf(“concatenation of ten strings using strcat is %s\n”,str1);
getch();
}

OUTPUT:

..To concatenate ten strings using strcat…

Enter first string


one

Enter next string to concatenate


two

Enter next string to concatenate


three

Enter next string to concatenate


four

Enter next string to concatenate


five

Enter next string to concatenate


six

Enter next string to concatenate


seven

Enter next string to concatenate


eight
Enter next string to concatenate
nine

Enter next string to concatenate


ten

Concatenation of ten strings using strcat is onetwothreefourfivesixseveneightnineten

www.programmingsimplysolved.com

write a C Program to concatenate two strings


without strcat function using pointers
write a c program to concatenate two strings without strcat function using pointers

#include<stdio.h>
#include<conio.h>
void main()
{
char *str1, *str2;
printf(” … c program to concatenate two strings without strcat() using arrays…”)
printf(“Enter first string “);
gets(str1);
printf(“Enter second string “);
gets(str2);
while (*str1!=’\0′)
*str1++ ;
while (*str2!=’\0′)
*str1++=*str2++
printf(“concatenation of two strings without strcat using pointers is %s\n”,str1);
getch();
}

OUTPUT:

… c program to concatenate two strings without strcat using pointers…

Enter first string


programming
Enter second string
simplysolved
concatenation of two strings without strcat using pointers is
programmingsimplysolved
write a C Program to concatenate two strings
without strcat function using functions
write a c program to concatenate two strings without strcat function using pointers

#include<stdio.h>
#include<conio.h>
void main()
{
char *str1, *str2;
printf(” … To concatenate two strings without strcat() using functions…”)
printf(“Enter first string “);
gets(str1);
printf(“Enter second string “);
gets(str2);
str_concatinate(*str1, *str2)
getch();
}

void str_concatinate(char *string1, char *string2)


{
while (*string1!=’\0′)
*string1++ ;
while (*string2!=’\0′)
*string1++=*string2++;
printf(“concatenation of two strings without strcat using functions is %s\n”,string1);
}

OUTPUT:

… To concatenate two strings without strcat using functions;…

Enter first string


programming
Enter second string
simplysolved
concatenation of two strings without strcat using functions is
programmingsimplysolved

You might also like