C strcat - String concatenate function in C with Example

<<Previous

Next >>




strcmp() - String Compare        strcpy() - String Copy        strlen() - String Length



String Concatenate function strcat(str1, str2) is used in C and C++ programming to concatenate two strings. strcat appends one string at the end of another string. string.h is used.

strcat Exact Syntax in C programming

Syntax:
	char *strcat ( char *dest, const char *src );

In simple terms, it takes 2 strings as parameters and returns a concatenated String

	Concatenated-String strcat ( String1, String2);

Example C program using strcat()

#include<stdio.h>

#include<string.h>


main()
{
  char first[] = "SPRING";
  char second[] = "WELCOME";
  char result;

  printf(" The first string is %s ",first);
  printf(" \n The second string is %s ",second);

  result = strcat(second,first);
  printf(" \n The concatenate of two strings are %s = ",result);
  return(0);
}

Output:

The first string is SPRING
The second string is WELCOME
The concatenate of two strings are WELCOME SPRING

strncat() - String n Concatenation        strlwr() - String Lower       

strncmp() - String n Compare        strncpy() - String n Copy






<< Previous

Next >>




strcat() - String Concatenation        strcmp() - String Compare


strcpy() - String Copy        strlen() - String Length














C strcat - String concatenate function in C with Example

<<Previous

Next >>




strcmp() - String Compare        strcpy() - String Copy        strlen() - String Length



String Concatenate function strcat(str1, str2) is used in C and C++ programming to concatenate two strings. strcat appends one string at the end of another string. string.h is used.

strcat Exact Syntax in C programming

Syntax:
	char *strcat ( char *dest, const char *src );

In simple terms, it takes 2 strings as parameters and returns a concatenated String

	Concatenated-String strcat ( String1, String2);

Example C program using strcat()

#include<stdio.h>

#include<string.h>


main()
{
  char first[] = "SPRING";
  char second[] = "WELCOME";
  char result;

  printf(" The first string is %s ",first);
  printf(" \n The second string is %s ",second);

  result = strcat(second,first);
  printf(" \n The concatenate of two strings are %s = ",result);
  return(0);
}

Output:

The first string is SPRING
The second string is WELCOME
The concatenate of two strings are WELCOME SPRING

strncat() - String n Concatenation        strlwr() - String Lower       

strncmp() - String n Compare        strncpy() - String n Copy






<< Previous

Next >>






strncat() - String n Concatenation        strlwr() - String Lower       

strncmp() - String n Compare       strncpy() - String n Copy