K & R C Programs Exercise 5-3.

K and R C, Solution to Exercise 5-3:
K and R C Programs Exercises provides the solution to all the exercises in the C Programming Language (2nd Edition). You can learn and solve K&R C Programs Exercise.
C Program to concatenate the two strings using the pointers
This program shows, how the standard library function “strcat” works!. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/


#include <stdio.h>
/* str_cat: concatenate t to the end of s: pointer version */
void str_cat(char *s, char *t)
{
/* run through the destination string until we point at the terminating '' */
while('' != *s)
{

++s;
}

/* now copy until we run out of string to copy */
while('' != (*s = *t))
{
++s;
++t;
}

}
int main(void)
{
char Str1[8192] ;
char Str2[8192] ;
printf("n Enter the first string: n");
scanf("%s",Str1);
printf("n Enter the second string: n");
scanf("%s",Str2);
printf("String one is (%s)n", Str1);
printf("String two is (%s)n", Str2);

str_cat(Str1, Str2);
printf("The combined string is (%s)n", Str1);

return 0;
}


C BasicC StringsK and R C Programs ExerciseYou can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com

Leave a Reply