<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN">
		<id>http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=String_-_char_array</id>
		<title>String - char array - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=String_-_char_array"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=String_-_char_array&amp;action=history"/>
		<updated>2026-05-02T14:08:31Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=String_-_char_array&amp;diff=15745&amp;oldid=prev</id>
		<title>2016年5月23日 (一) 02:39 Pppeng</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=String_-_char_array&amp;diff=15745&amp;oldid=prev"/>
				<updated>2016-05-23T02:39:54Z</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;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;zh-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;2016年5月23日 (一) 02:39的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l60&quot; &gt;第60行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第60行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[https://www.microduino.cn/wiki/index.php/Arduino_%E8%AF%AD%E6%B3%95%E6%89%8B%E5%86%8C/zh 返回Arduino语法手册]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Pppeng</name></author>	</entry>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=String_-_char_array&amp;diff=15703&amp;oldid=prev</id>
		<title>Pppeng：创建页面，内容为“string（字符串）&lt;br&gt; *'''描述'''&lt;br&gt;  文本字符串可以有两种表现形式。你可以使用字符串数据类型（这是0019版本的核心部分）...”</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=String_-_char_array&amp;diff=15703&amp;oldid=prev"/>
				<updated>2016-05-23T01:56:45Z</updated>
		
		<summary type="html">&lt;p&gt;创建页面，内容为“string（字符串）&amp;lt;br&amp;gt; *&amp;#039;&amp;#039;&amp;#039;描述&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;  文本字符串可以有两种表现形式。你可以使用字符串数据类型（这是0019版本的核心部分）...”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;string（字符串）&amp;lt;br&amp;gt;&lt;br /&gt;
*'''描述'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
文本字符串可以有两种表现形式。你可以使用字符串数据类型（这是0019版本的核心部分），或者你可以做一个字符串，由char类型的数组和空终止字符('\0')构成。&lt;br /&gt;
而字符串对象（String object）将让你拥有更多的功能，同时也消耗更多的内存资源。&amp;lt;br&amp;gt;&lt;br /&gt;
*'''举例'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
以下所有字符串都是有效的声明。&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:green&amp;quot;&amp;gt;&lt;br /&gt;
  char Str1[15];&lt;br /&gt;
  char Str2[8] = {'a', 'r', 'd', 'u', 'i', 'n', 'o'};&lt;br /&gt;
  char Str3[8] = {'a', 'r', 'd', 'u', 'i', 'n', 'o', '\0'};&lt;br /&gt;
  char Str4[ ] = &amp;quot;arduino&amp;quot;;&lt;br /&gt;
  char Str5[8] = &amp;quot;arduino&amp;quot;;&lt;br /&gt;
  char Str6[15] = &amp;quot;arduino&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
声明字符串的解释&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
在Str1中 声明一个没有初始化的字符数组&amp;lt;br&amp;gt;&lt;br /&gt;
在Str2中 声明一个字符数组（包括一个附加字符），编译器会自动添加所需的空字符&amp;lt;br&amp;gt;&lt;br /&gt;
在Str3中 明确加入空字符&amp;lt;br&amp;gt;&lt;br /&gt;
在Str4中 用引号分隔初始化的字符串常数，编译器将调整数组的大小，以适应字符串常量和终止空字符&amp;lt;br&amp;gt;&lt;br /&gt;
在Str5中 初始化一个包括明确的尺寸和字符串常量的数组&amp;lt;br&amp;gt;&lt;br /&gt;
在Str6中 初始化数组，预留额外的空间用于一个较大的字符串&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
空终止字符&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
一般来说，字符串的结尾有一个空终止字符（ASCII代码0）。以此让功能函数（例如Serial.pring()）知道一个字符串的结束。否则，他们将从内存继续读取后续字节，而这些并不属于所需字符串的一部分。&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
这意味着，你的字符串比你想要的文字包含更多的个字符空间。这就是为什么Str2和Str5需要八个字符，即使“Arduino”只有七个字符 - 最后一个位置会自动填充空字符。str4将自动调整为八个字符，包括一个额外的空。在Str3的，我们自己已经明确地包含了空字符(写入'\ 0')。&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
需要注意的是，字符串可能没有一个最后的空字符（例如在Str2中您已定义字符长度为7，而不是8）。这会破坏大部分使用字符串的功能，所以不要故意而为之。如果你注意到一些奇怪的现象（在字符串中操作字符），基本就是这个原因导致的了。&amp;lt;br&amp;gt;&lt;br /&gt;
单引号？还是双引号？&lt;br /&gt;
&lt;br /&gt;
定义字符串时使用双引号（例如“ABC”），而定义一个单独的字符时使用单引号（例如'A'）&amp;lt;br&amp;gt;&lt;br /&gt;
包装长字符串&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
你可以像这样打包长字符串： char myString[] = “This is the first line” ” this is the second line” ” etcetera”;&amp;lt;br&amp;gt;&lt;br /&gt;
字符串数组&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
当你的应用包含大量的文字，如带有液晶显示屏的一个项目，建立一个字符串数组是非常便利的。因为字符串本身就是数组，它实际上是一个两维数组的典型。&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
在下面的代码，”char*”在字符数据类型char后跟了一个星号'*'表示这是一个“指针”数组。所有的数组名实际上是指针，所以这需要一个数组的数组。指针对于C语言初学者而言是非常深奥的部分之一，但我们没有必要了解详细指针，就可以有效地应用它。&amp;lt;br&amp;gt;&lt;br /&gt;
*'''样例'''&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:green&amp;quot;&amp;gt;&lt;br /&gt;
char* myStrings[]={&lt;br /&gt;
  &amp;quot;This is string 1&amp;quot;, &amp;quot;This is string 2&amp;quot;, &amp;quot;This is string 3&amp;quot;,&lt;br /&gt;
  &amp;quot;This is string 4&amp;quot;, &amp;quot;This is string 5&amp;quot;,&amp;quot;This is string 6&amp;quot;};&lt;br /&gt;
 &lt;br /&gt;
void setup(){&lt;br /&gt;
  Serial.begin(9600);&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
void loop(){&lt;br /&gt;
  for (int i = 0; i &amp;lt; 6; i++){&lt;br /&gt;
    Serial.println(myStrings[i]);&lt;br /&gt;
    delay(500);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pppeng</name></author>	</entry>

	</feed>