📄 c++ builder 初学问与答(十六).htm
字号:
lang=EN-US><o:p></o:p></SPAN></B></FONT></P>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 23.5pt"><FONT
size=3><B><SPAN lang=EN-US>3</SPAN></B><B><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">)</SPAN><SPAN
lang=EN-US>AnsiString</SPAN></B><B><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">与</SPAN><SPAN
lang=EN-US>String</SPAN></B><B><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">有什么区别?</SPAN><SPAN
lang=EN-US><o:p></o:p></SPAN></B></FONT></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><FONT
size=3><B><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">答:</SPAN></B><SPAN
lang=EN-US> C++ Builder</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">在</SPAN><SPAN
lang=EN-US>Sysdefs.h</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">头文件中有这样的定义:</SPAN></FONT></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN
lang=EN-US><FONT size=3>typedef<SPAN
style="mso-spacerun: yes"> </SPAN>AnsiString
String;</FONT></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''"><FONT
size=3>从这一点在看他二者是完全一样的,只是书写起来后者更方便一些,前者是意图更明了一些。</FONT></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><FONT
size=3><B><SPAN lang=EN-US>4</SPAN></B><B><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">)能介绍一下</SPAN><SPAN
lang=EN-US>AnsiString</SPAN></B><B><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">类的一些常见函数及其用法吗?</SPAN><SPAN
lang=EN-US><o:p></o:p></SPAN></B></FONT></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><FONT
size=3><B><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">答:</SPAN></B><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">当然可以了,下面就常见函数做一下简单介绍:</SPAN></FONT></P>
<TABLE
style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt"
cellSpacing=0 cellPadding=0 border=1>
<TBODY>
<TR>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 62.4pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"
vAlign=top width=83>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">成员函数</SPAN></P></TD>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 238.1pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; mso-border-left-alt: solid windowtext .5pt"
vAlign=top width=317>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">语法</SPAN></P></TD>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 136.2pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; mso-border-left-alt: solid windowtext .5pt"
vAlign=top width=182>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">功能</SPAN></P></TD></TR>
<TR>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 62.4pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=83>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
lang=EN-US>c_str</SPAN></P></TD>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 238.1pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=317>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
lang=EN-US>char *_fastcall c_str() const</SPAN></P></TD>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 136.2pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=182>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">返回字符串数据的指针</SPAN></P></TD></TR>
<TR>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 62.4pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=83>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
lang=EN-US>Delete</SPAN></P></TD>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 238.1pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=317>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
lang=EN-US>void _fastcall Delete(int index,int
count)</SPAN></P></TD>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 136.2pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=182>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">由</SPAN><SPAN
lang=EN-US>index</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">处开始删除</SPAN><SPAN
lang=EN-US>count</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">个字符</SPAN></P></TD></TR>
<TR>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 62.4pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=83>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
lang=EN-US>Insert</SPAN></P></TD>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 238.1pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=317>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
lang=EN-US>void _fastcall Insert(const AnsiString& str,int
index)</SPAN></P></TD>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 136.2pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=182>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">由</SPAN><SPAN
lang=EN-US>index</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">处开始插入字符</SPAN><SPAN
lang=EN-US>str</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">到原字符串中</SPAN></P></TD></TR>
<TR>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 62.4pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=83>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
lang=EN-US>IsEmpty</SPAN></P></TD>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 238.1pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=317>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
lang=EN-US>bool _fastcall IsEmpty() const</SPAN></P></TD>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 136.2pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=182>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">返回字符串是否为空,</SPAN><SPAN
lang=EN-US>true</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">表示空字符串</SPAN></P></TD></TR>
<TR>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 62.4pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=83>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
lang=EN-US>Length</SPAN></P></TD>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 238.1pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=317>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
lang=EN-US>int _fastcall Length() const</SPAN></P></TD>
<TD
style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 136.2pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=182>
<P class=MsoNormalIndent
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 0cm"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: ''''Times New Roman''''; mso-hansi-font-family: ''''Times New Roman''''">返回字符串长度</SPAN></P></TD></TR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -