string function strcat c++ example

string function strcat c++ example
Di Posting Oleh : Simple Learning
Kategori : strcat string

Strcat function comes from the string class with string.h header file. It takes two strings as parameters and return second string append to the first string with putting null character at the end of the string.


Example C++ program 
A C++ program which takes two strings as input from user each of type char and concatenates them with the help of strcat function and displays the result.

See also: concatenate two string without using strcat

strcat example C++ source code

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

using namespace
std;

int
main()
{

char
str1[100],str2[100];

cout<<"\nEnter first string: ";
gets(str1);

cout<<"\nEnter second string: ";
gets(str2);

strcat(str1, str2);

cout<<"\n\n\t\Resultant first String after concatenation: "<<endl;
cout<<"\n\n\t\t\t"<<str1<<"\n\n\t\t\t";

return
0;
}



Input Output
strcat example c++ source code

Its a simple program example it is recommended to change the code and examine the output. Happy learning C++

0 Response to "string function strcat c++ example"

Post a Comment