A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2FString%2FString_Append</id>
		<title>C/String/String Append - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2FString%2FString_Append"/>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C/String/String_Append&amp;action=history"/>
		<updated>2026-04-18T00:03:32Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.cppe.ru/index.php?title=C/String/String_Append&amp;diff=148&amp;oldid=prev</id>
		<title> в 14:20, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C/String/String_Append&amp;diff=148&amp;oldid=prev"/>
				<updated>2010-05-25T14:20:56Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 14:20, 25 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.cppe.ru/index.php?title=C/String/String_Append&amp;diff=149&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C/String/String_Append&amp;diff=149&amp;oldid=prev"/>
				<updated>2010-05-25T10:22:19Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия: Импорт контента...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Append string: how to use strcat==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
int main ()&lt;br /&gt;
{&lt;br /&gt;
  char str[80];&lt;br /&gt;
  strcpy (str,&amp;quot;part I,  &amp;quot;);&lt;br /&gt;
  strcat (str,&amp;quot;part II, &amp;quot;);&lt;br /&gt;
  strcat (str,&amp;quot;part III.&amp;quot;);&lt;br /&gt;
  puts (str);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Append string: strncat==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
  char s1[80], s2[80];&lt;br /&gt;
  unsigned int len;&lt;br /&gt;
  gets(s1);&lt;br /&gt;
  gets(s2);&lt;br /&gt;
  len = 79 - strlen(s2);&lt;br /&gt;
  strncat(s2, s1, len);&lt;br /&gt;
  printf(s2);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Append string to another string==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
  char s1[80], s2[80];&lt;br /&gt;
  gets(s1);&lt;br /&gt;
  gets(s2);&lt;br /&gt;
  strcat(s2, s1);&lt;br /&gt;
  printf(s2);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Append substring to string: strncat==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
int main ()&lt;br /&gt;
{&lt;br /&gt;
  char str1[20];&lt;br /&gt;
  char str2[20];&lt;br /&gt;
  strcpy (str1,&amp;quot;qqq34567790&amp;quot;);&lt;br /&gt;
  strcpy (str2,&amp;quot;333333&amp;quot;);&lt;br /&gt;
  strncat (str1, str2, 6);&lt;br /&gt;
  puts (str1);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Demonstrates how to put strings together using strcat==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    char first[100];&lt;br /&gt;
    char last[100];&lt;br /&gt;
    char full_name[200];&lt;br /&gt;
    strcpy(first, &amp;quot;firstName&amp;quot;);&lt;br /&gt;
    strcpy(last, &amp;quot;secondName&amp;quot;);&lt;br /&gt;
    strcpy(full_name, first);&lt;br /&gt;
    strcat(full_name, &amp;quot; &amp;quot;);&lt;br /&gt;
    strcat(full_name, last);&lt;br /&gt;
    printf(&amp;quot;The full name is %s\n&amp;quot;, full_name);&lt;br /&gt;
    return (0);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Get first and last name and print them together==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
int main() {&lt;br /&gt;
    char first[100];&lt;br /&gt;
    char last[100];&lt;br /&gt;
    char full[100];&lt;br /&gt;
&lt;br /&gt;
    printf(&amp;quot;Enter first name: &amp;quot;);&lt;br /&gt;
    fgets(first, sizeof(first), stdin);&lt;br /&gt;
    /* trim off last character */&lt;br /&gt;
    first[strlen(first)-1] = &amp;quot;\0&amp;quot;;&lt;br /&gt;
    printf(&amp;quot;Enter last name: &amp;quot;);&lt;br /&gt;
    fgets(last, sizeof(last), stdin);&lt;br /&gt;
    /* trim off last character */&lt;br /&gt;
    last[strlen(last)-1] = &amp;quot;\0&amp;quot;;&lt;br /&gt;
    strcpy(full, first);&lt;br /&gt;
    strcat(full, &amp;quot; &amp;quot;);&lt;br /&gt;
    strcat(full, last);&lt;br /&gt;
    printf(&amp;quot;The name is %s\n&amp;quot;, full);&lt;br /&gt;
    return (0);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Join strings==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
/*  Joining strings */&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
  char str1[40] = &amp;quot;To be or not to be&amp;quot;;&lt;br /&gt;
  char str2[40] = &amp;quot;,that is the question&amp;quot;;&lt;br /&gt;
  int count1 = 0;                /* Length of str1 */&lt;br /&gt;
  int count2 = 0;                /* Length of str2 */&lt;br /&gt;
  /* find the length of str1 */&lt;br /&gt;
  while (str1[count1] != &amp;quot;\0&amp;quot;)   /* Increment count till we reach the terminating character*/&lt;br /&gt;
    count1++;                   &lt;br /&gt;
  &lt;br /&gt;
  /* Find the length of str2 */&lt;br /&gt;
  while (str2[count2] != &amp;quot;\0&amp;quot;)  /* Count characters in second string      */&lt;br /&gt;
    count2++;&lt;br /&gt;
  &lt;br /&gt;
  /* Check that we have enough space for both strings  */&lt;br /&gt;
  if(sizeof str1 &amp;lt; count1 + count2 + 1)&lt;br /&gt;
    printf(&amp;quot;\nYou can&amp;quot;t put a quart into a pint pot.&amp;quot;);&lt;br /&gt;
  else&lt;br /&gt;
  {  /* Copy 2nd string to end of the first  */&lt;br /&gt;
     count2 = 0;                 /* Reset index for str2 to 0   */&lt;br /&gt;
    while(str2[count2] != &amp;quot;\0&amp;quot;)  /* Copy up to null from str2   */&lt;br /&gt;
      str1[count1++] = str2[count2++];&lt;br /&gt;
    str1[count1] = &amp;quot;\0&amp;quot;;         /* Make sure we add terminator */&lt;br /&gt;
    printf(&amp;quot;\n%s\n&amp;quot;, str1 );     /* Output combined string      */&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Join strings: revitalised: strlen and strcat==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#define STR_LENGTH 40&lt;br /&gt;
void main() {&lt;br /&gt;
  char str1[STR_LENGTH] = &amp;quot;String in C&amp;quot;;&lt;br /&gt;
  char str2[STR_LENGTH] = &amp;quot;,String in C&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  if(STR_LENGTH &amp;gt; strlen(str1) + strlen(str2)) /* Enough space ?              */&lt;br /&gt;
    printf(&amp;quot;\n%s\n&amp;quot;, strcat(str1, str2) );     /* yes, so print joined string */&lt;br /&gt;
  else&lt;br /&gt;
    printf(&amp;quot;\n no enough room.&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==String concatenate==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#define concat(a, b)  a ## b&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
  int xy = 10;&lt;br /&gt;
  printf(&amp;quot;%d&amp;quot;, concat(x, y));&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>