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_Length</id>
		<title>C/String/String Length - История изменений</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_Length"/>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C/String/String_Length&amp;action=history"/>
		<updated>2026-04-17T21:33:01Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.cppe.ru/index.php?title=C/String/String_Length&amp;diff=136&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_Length&amp;diff=136&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_Length&amp;diff=137&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_Length&amp;diff=137&amp;oldid=prev"/>
				<updated>2010-05-25T10:22:16Z</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;==Add null terminator to string end==&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;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
  char s[256], *p;&lt;br /&gt;
  p = s;&lt;br /&gt;
  while((*p++ = getchar())!= &amp;quot;\n&amp;quot;) ;&lt;br /&gt;
  *p = &amp;quot;\0&amp;quot;; /* add null terminator */&lt;br /&gt;
  printf(s);&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;
==Check string length and set string end==&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 str[10];&lt;br /&gt;
  int i;&lt;br /&gt;
  printf(&amp;quot;Enter a string: &amp;quot;);&lt;br /&gt;
  fgets(str, 10, stdin);&lt;br /&gt;
  /* remove newline, if present */&lt;br /&gt;
  i = strlen(str) - 1;&lt;br /&gt;
  &lt;br /&gt;
  if(str[i] ==&amp;quot;\n&amp;quot;) &lt;br /&gt;
      str[i] = &amp;quot;\0&amp;quot;;&lt;br /&gt;
  printf(&amp;quot;This is your string: %s&amp;quot;, 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;
==Computes the length of a line==&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;
int main()&lt;br /&gt;
{&lt;br /&gt;
    char line[100];&lt;br /&gt;
    printf(&amp;quot;Enter a line: &amp;quot;);&lt;br /&gt;
    fgets(line, sizeof(line), stdin);&lt;br /&gt;
    printf(&amp;quot;The length of the line is: %d\n&amp;quot;, strlen(line));&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;
== Get length of substring composed of given characters==&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;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
  int len;&lt;br /&gt;
  len = strspn(&amp;quot;this is a test&amp;quot;, &amp;quot;siht &amp;quot;);&lt;br /&gt;
  printf(&amp;quot;%d&amp;quot;, len);&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 length of substring composed of given characters: how to use strspn==&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;
  int i;&lt;br /&gt;
  char key[] = &amp;quot;890th&amp;quot;;&lt;br /&gt;
  char str[] = &amp;quot;1234567890&amp;quot;;&lt;br /&gt;
  i = strspn (key, str);&lt;br /&gt;
  &lt;br /&gt;
  printf (&amp;quot;Length of initial number is %d\n&amp;quot;, i);&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;
==Get the string length==&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 str[80];&lt;br /&gt;
  gets(str);&lt;br /&gt;
  printf(&amp;quot;Length is %d&amp;quot;, strlen(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;
==Lengths of strings==&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;
void main() {&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 count = 0;                &lt;br /&gt;
  while (str1[count] != &amp;quot;\0&amp;quot;)   &lt;br /&gt;
    count++; &lt;br /&gt;
  printf(&amp;quot;\nThe length of the string \&amp;quot;%s\&amp;quot; is %d characters.&amp;quot;, str1, count);&lt;br /&gt;
  count = 0; &lt;br /&gt;
  while (str2[count] != &amp;quot;\0&amp;quot;)&lt;br /&gt;
    count++;&lt;br /&gt;
  printf(&amp;quot;\nThe length of the string \&amp;quot;%s\&amp;quot; is %d characters.\n&amp;quot;, str2, count);&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;
==print the string forward and backwards==&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;
char *p = &amp;quot;hello world&amp;quot;;&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
  register int t;&lt;br /&gt;
  printf(p);&lt;br /&gt;
  &lt;br /&gt;
  for( t = strlen( p ) - 1; t &amp;gt; -1; t--) &lt;br /&gt;
      printf(&amp;quot;%c&amp;quot;, p[ t ]);&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;
== Return string length: how to use strlen==&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[256];&lt;br /&gt;
  printf (&amp;quot;Enter a sentence: &amp;quot;);&lt;br /&gt;
  gets (str);&lt;br /&gt;
  printf ( &amp;quot;%s is %u characters long\n&amp;quot;, str, strlen( 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;
==String length==&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;
int length(char string[]) {&lt;br /&gt;
    int index;&lt;br /&gt;
    for (index = 0; string[index] != &amp;quot;\0&amp;quot;; ++index)&lt;br /&gt;
        continue;&lt;br /&gt;
    return (index);&lt;br /&gt;
}&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
     char line[100];&lt;br /&gt;
     while (1) {&lt;br /&gt;
        printf(&amp;quot;Enter line:&amp;quot;);&lt;br /&gt;
        fgets(line, sizeof(line), stdin);&lt;br /&gt;
      printf(&amp;quot;Length (including newline) is: %d\n&amp;quot;, length(line));&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;
==String operator: get length, compare and find a char==&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;
  printf(&amp;quot;lengths: %d %d\n&amp;quot;, strlen(s1), strlen(s2));&lt;br /&gt;
  if(!strcmp(s1, s2)) &lt;br /&gt;
      printf(&amp;quot;The strings are equal\n&amp;quot;);&lt;br /&gt;
  strcat(s1, s2);&lt;br /&gt;
  printf(&amp;quot;%s\n&amp;quot;, s1);&lt;br /&gt;
  strcpy(s1, &amp;quot;This is a test.\n&amp;quot;);&lt;br /&gt;
  printf(s1);&lt;br /&gt;
  &lt;br /&gt;
  if(strchr(&amp;quot;hello&amp;quot;, &amp;quot;e&amp;quot;)) &lt;br /&gt;
       printf(&amp;quot;e is in hello\n&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
  if(strstr(&amp;quot;hi there&amp;quot;, &amp;quot;hi&amp;quot;)) &lt;br /&gt;
      printf(&amp;quot;found hi&amp;quot;);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&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>