{"id":72,"date":"2021-09-20T09:21:18","date_gmt":"2021-09-20T09:21:18","guid":{"rendered":"https:\/\/ethosspace.com\/programmers\/?p=72"},"modified":"2021-10-11T11:53:22","modified_gmt":"2021-10-11T11:53:22","slug":"concat-two-strings-without-using-library-or-string-function-in-c","status":"publish","type":"post","link":"https:\/\/ethosspace.com\/programmers\/concat-two-strings-without-using-library-or-string-function-in-c\/","title":{"rendered":"Concat two strings without using Library or string function in C"},"content":{"rendered":"\n<p>In this program we are accepting two strings from user using Gets. After that by calculating length of first string program is using for loop to append each character of second string to first string.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>\/* Program Name: Concatenate Two String without using in built-in function concat.\n*\/\n#include&lt;stdio.h&gt;\n#include&lt;string.h&gt;\nvoid main() \n{\n\tchar string1&#91;150], string2&#91;100];\n\tint str1Len,str2Len;\n\t\n\tprintf(\"\\nEnter String 1 :\\t\");\n\tgets(string1);\n\tprintf(\"\\nEnter String 2 :\\t\");\n\tgets(string2);\n\t\n\t\/\/identify entered string length using strlen function.\n\tstr1Len=strlen(string1);\n\t\n\t\/\/ now using for loop we will add second string into first character by character.\n\tfor (str2Len=0;string2&#91;str2Len]!='\\0';str1Len++,str2Len++)\n\tstring1&#91;str1Len]=string2&#91;str2Len];\n\tstring1&#91;str1Len]='\\0';\n\t\n\tprintf(\"\\n\\nConcated string is :\\t%s\", string1);\n\n}\n\n<\/code><\/pre>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<div class=\"wp-block-columns has-white-color has-cyan-bluish-gray-background-color has-text-color has-background is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-code\"><code>\nEnter String 1 :        Learning C Language\n\nEnter String 2 :        Is Easy\n\n\nConcated string is :    Learning C LanguageIs Easy<\/code><\/pre>\n<\/div>\n<\/div>\n\n\n","protected":false},"excerpt":{"rendered":"<p>In this program we are accepting two strings from user using Gets. After that by calculating length of first string program is using for loop to append each character of second string to first string. Output<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[6],"tags":[],"class_list":["post-72","post","type-post","status-publish","format-standard","hentry","category-c-language"],"aioseo_notices":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"sparkling-featured":false,"sparkling-featured-fullwidth":false,"tab-small":false},"uagb_author_info":{"display_name":"program45_-rt8nb","author_link":"https:\/\/ethosspace.com\/programmers\/author\/program45_-rt8nb\/"},"uagb_comment_info":0,"uagb_excerpt":"In this program we are accepting two strings from user using Gets. After that by calculating length of first string program is using for loop to append each character of second string to first string. Output","_links":{"self":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/72","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/comments?post=72"}],"version-history":[{"count":3,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/72\/revisions"}],"predecessor-version":[{"id":279,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/72\/revisions\/279"}],"wp:attachment":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/media?parent=72"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/categories?post=72"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/tags?post=72"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}