{"id":128,"date":"2018-09-28T15:25:20","date_gmt":"2018-09-28T15:25:20","guid":{"rendered":"http:\/\/www.recologypower.com:6671\/?p=128"},"modified":"2018-09-28T15:25:20","modified_gmt":"2018-09-28T15:25:20","slug":"c%e8%af%ad%e8%a8%80%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%93%8d%e4%bd%9c%e6%80%bb%e7%bb%93%e5%a4%a7%e5%85%a8%e8%b6%85%e8%af%a6%e7%bb%86","status":"publish","type":"post","link":"http:\/\/www.recologypower.com:9080\/?p=128","title":{"rendered":"C\u8bed\u8a00\u5b57\u7b26\u4e32\u64cd\u4f5c\u603b\u7ed3\u5927\u5168(\u8d85\u8be6\u7ec6)"},"content":{"rendered":"<p><strong>1\uff09\u5b57\u7b26\u4e32\u64cd\u4f5c<br \/>\n<\/strong>strcpy(p, p1) \u590d\u5236\u5b57\u7b26\u4e32<br \/>\nstrncpy(p, p1, n) \u590d\u5236\u6307\u5b9a\u957f\u5ea6\u5b57\u7b26\u4e32<br \/>\nstrcat(p, p1) \u9644\u52a0\u5b57\u7b26\u4e32<br \/>\nstrncat(p, p1, n) \u9644\u52a0\u6307\u5b9a\u957f\u5ea6\u5b57\u7b26\u4e32<br \/>\nstrlen(p) \u53d6\u5b57\u7b26\u4e32\u957f\u5ea6<br \/>\nstrcmp(p, p1) \u6bd4\u8f83\u5b57\u7b26\u4e32<br \/>\nstrcasecmp\u5ffd\u7565\u5927\u5c0f\u5199\u6bd4\u8f83\u5b57\u7b26\u4e32<br \/>\nstrncmp(p, p1, n) \u6bd4\u8f83\u6307\u5b9a\u957f\u5ea6\u5b57\u7b26\u4e32<br \/>\nstrchr(p, c) \u5728\u5b57\u7b26\u4e32\u4e2d\u67e5\u627e\u6307\u5b9a\u5b57\u7b26<br \/>\nstrrchr(p, c) \u5728\u5b57\u7b26\u4e32\u4e2d\u53cd\u5411\u67e5\u627e<br \/>\nstrstr(p, p1) \u67e5\u627e\u5b57\u7b26\u4e32<br \/>\nstrpbrk(p, p1) \u4ee5\u76ee\u6807\u5b57\u7b26\u4e32\u7684\u6240\u6709\u5b57\u7b26\u4f5c\u4e3a\u96c6\u5408\uff0c\u5728\u5f53\u524d\u5b57\u7b26\u4e32\u67e5\u627e\u8be5\u96c6\u5408\u7684\u4efb\u4e00\u5143\u7d20<br \/>\nstrspn(p, p1) \u4ee5\u76ee\u6807\u5b57\u7b26\u4e32\u7684\u6240\u6709\u5b57\u7b26\u4f5c\u4e3a\u96c6\u5408\uff0c\u5728\u5f53\u524d\u5b57\u7b26\u4e32\u67e5\u627e\u4e0d\u5c5e\u4e8e\u8be5\u96c6\u5408\u7684\u4efb\u4e00\u5143\u7d20\u7684\u504f\u79fb<br \/>\nstrcspn(p, p1) \u4ee5\u76ee\u6807\u5b57\u7b26\u4e32\u7684\u6240\u6709\u5b57\u7b26\u4f5c\u4e3a\u96c6\u5408\uff0c\u5728\u5f53\u524d\u5b57\u7b26\u4e32\u67e5\u627e\u5c5e\u4e8e\u8be5\u96c6\u5408\u7684\u4efb\u4e00\u5143\u7d20\u7684\u504f\u79fb<br \/>\n* \u5177\u6709\u6307\u5b9a\u957f\u5ea6\u7684\u5b57\u7b26\u4e32\u5904\u7406\u51fd\u6570\u5728\u5df2\u5904\u7406\u7684\u5b57\u7b26\u4e32\u4e4b\u540e\u586b\u8865\u96f6\u7ed3\u5c3e\u7b26<\/p>\n<p><strong>2\uff09\u5b57\u7b26\u4e32\u5230\u6570\u503c\u7c7b\u578b\u7684\u8f6c\u6362<br \/>\n<\/strong>strtod(p, ppend) \u4ece\u5b57\u7b26\u4e32 p \u4e2d\u8f6c\u6362 double \u7c7b\u578b\u6570\u503c\uff0c\u5e76\u5c06\u540e\u7eed\u7684\u5b57\u7b26\u4e32\u6307\u9488\u5b58\u50a8\u5230 ppend \u6307\u5411\u7684 char* \u7c7b\u578b\u5b58\u50a8\u3002<br \/>\nstrtol(p, ppend, base) \u4ece\u5b57\u7b26\u4e32 p \u4e2d\u8f6c\u6362 long \u7c7b\u578b\u6574\u578b\u6570\u503c\uff0cbase \u663e\u5f0f\u8bbe\u7f6e\u8f6c\u6362\u7684\u6574\u578b\u8fdb\u5236\uff0c\u8bbe\u7f6e\u4e3a 0 \u4ee5\u6839\u636e\u7279\u5b9a\u683c\u5f0f\u5224\u65ad\u6240\u7528\u8fdb\u5236\uff0c0x, 0X \u524d\u7f00\u4ee5\u89e3\u91ca\u4e3a\u5341\u516d\u8fdb\u5236\u683c\u5f0f\u6574\u578b\uff0c0 \u00a0\u00a0\u00a0\u524d\u7f00\u4ee5\u89e3\u91ca\u4e3a\u516b\u8fdb\u5236\u683c\u5f0f\u6574\u578b<br \/>\natoi(p) \u5b57\u7b26\u4e32\u8f6c\u6362\u5230 int \u6574\u578b<br \/>\natof(p) \u5b57\u7b26\u4e32\u8f6c\u6362\u5230 double \u7b26\u70b9\u6570<br \/>\natol(p) \u5b57\u7b26\u4e32\u8f6c\u6362\u5230 long \u6574\u578b<\/p>\n<p><strong>3\uff09\u5b57\u7b26\u68c0\u67e5<br \/>\n<\/strong>isalpha() \u68c0\u67e5\u662f\u5426\u4e3a\u5b57\u6bcd\u5b57\u7b26<br \/>\nisupper() \u68c0\u67e5\u662f\u5426\u4e3a\u5927\u5199\u5b57\u6bcd\u5b57\u7b26<br \/>\nislower() \u68c0\u67e5\u662f\u5426\u4e3a\u5c0f\u5199\u5b57\u6bcd\u5b57\u7b26<br \/>\nisdigit() \u68c0\u67e5\u662f\u5426\u4e3a\u6570\u5b57<br \/>\nisxdigit() \u68c0\u67e5\u662f\u5426\u4e3a\u5341\u516d\u8fdb\u5236\u6570\u5b57\u8868\u793a\u7684\u6709\u6548\u5b57\u7b26<br \/>\nisspace() \u68c0\u67e5\u662f\u5426\u4e3a\u7a7a\u683c\u7c7b\u578b\u5b57\u7b26<br \/>\niscntrl() \u68c0\u67e5\u662f\u5426\u4e3a\u63a7\u5236\u5b57\u7b26<br \/>\nispunct() \u68c0\u67e5\u662f\u5426\u4e3a\u6807\u70b9\u7b26\u53f7<br \/>\nisalnum() \u68c0\u67e5\u662f\u5426\u4e3a\u5b57\u6bcd\u548c\u6570\u5b57<br \/>\nisprint() \u68c0\u67e5\u662f\u5426\u662f\u53ef\u6253\u5370\u5b57\u7b26<br \/>\nisgraph() \u68c0\u67e5\u662f\u5426\u662f\u56fe\u5f62\u5b57\u7b26\uff0c\u7b49\u6548\u4e8e isalnum() | ispunct()<\/p>\n<p><strong>4\uff09\u51fd\u6570\u539f\u578b<br \/>\n\u539f\u578b\uff1astrcpy(char destination[], const char source[]);<br \/>\n<\/strong>\u529f\u80fd\uff1a\u5c06\u5b57\u7b26\u4e32source\u62f7\u8d1d\u5230\u5b57\u7b26\u4e32destination\u4e2d<br \/>\n\u4f8b\u7a0b\uff1a<br \/>\n#include &lt;iostream.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\nvoid main(void)<br \/>\n{<br \/>\nchar str1[10] = { &#8220;TsinghuaOK&#8221;};<br \/>\nchar str2[10] = { &#8220;Computer&#8221;};<br \/>\ncout &lt;&lt;strcpy(str1,str2)&lt;&lt;endl;<br \/>\n}<\/p>\n<p>\u8fd0\u884c\u7ed3\u679c\u662f:Computer<br \/>\n\u7b2c\u4e8c\u4e2a\u5b57\u7b26\u4e32\u5c06\u8986\u76d6\u6389\u7b2c\u4e00\u4e2a\u5b57\u7b26\u4e32\u7684\u6240\u6709\u5185\u5bb9\uff01<br \/>\n\u6ce8\u610f\uff1a\u5728\u5b9a\u4e49\u6570\u7ec4\u65f6\uff0c\u5b57\u7b26\u6570\u7ec41\u7684\u5b57\u7b26\u4e32\u957f\u5ea6\u5fc5\u987b\u5927\u4e8e\u6216\u7b49\u4e8e\u5b57\u7b26\u4e322\u7684\u5b57\u7b26\u4e32\u957f\u5ea6\u3002\u4e0d\u80fd\u7528\u8d4b\u503c\u8bed\u53e5\u5c06\u4e00\u4e2a\u5b57\u7b26\u4e32\u5e38\u91cf\u6216\u5b57\u7b26\u6570\u7ec4\u76f4\u63a5\u8d4b\u7ed9\u4e00\u4e2a\u5b57\u7b26\u6570\u7ec4\u3002\u6240\u6709\u5b57\u7b26\u4e32\u5904\u7406\u51fd\u6570\u90fd\u5305\u542b\u5728\u5934\u6587\u4ef6string.h\u4e2d\u3002<\/p>\n<p><strong>strncpy(char destination[], const char source[], int numchars);<\/strong><\/p>\n<p>strncpy\uff1a\u5c06\u5b57\u7b26\u4e32source\u4e2d\u524dnumchars\u4e2a\u5b57\u7b26\u62f7\u8d1d\u5230\u5b57\u7b26\u4e32destination\u4e2d\u3002<br \/>\nstrncpy\u51fd\u6570\u5e94\u7528\u4e3e\u4f8b<br \/>\n\u539f\u578b\uff1astrncpy(char destination[], const char source[], int numchars);<br \/>\n\u529f\u80fd\uff1a\u5c06\u5b57\u7b26\u4e32source\u4e2d\u524dnumchars\u4e2a\u5b57\u7b26\u62f7\u8d1d\u5230\u5b57\u7b26\u4e32destination\u4e2d<br \/>\n\u4f8b\u7a0b\uff1a<\/p>\n<p>#include &lt;iostream.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\nvoid main(void)<br \/>\n{<br \/>\nchar str1[10] = { &#8220;Tsinghua &#8220;};<br \/>\nchar str2[10] = { &#8220;Computer&#8221;};<br \/>\ncout &lt;&lt;strncpy(str1,str2,3)&lt;&lt;endl;<br \/>\n}<\/p>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1aComnghua<br \/>\n\u6ce8\u610f\uff1a\u5b57\u7b26\u4e32source\u4e2d\u524dnumchars\u4e2a\u5b57\u7b26\u5c06\u8986\u76d6\u6389\u5b57\u7b26\u4e32destination\u4e2d\u524dnumchars\u4e2a\u5b57\u7b26\uff01<\/p>\n<p><strong>\u539f\u578b\uff1astrcat(char target[], const char source[]);<br \/>\n<\/strong>\u529f\u80fd\uff1a\u5c06\u5b57\u7b26\u4e32source\u63a5\u5230\u5b57\u7b26\u4e32target\u7684\u540e\u9762<br \/>\n\u4f8b\u7a0b\uff1a<br \/>\n#include &lt;iostream.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\nvoid main(void)<br \/>\n{<br \/>\nchar str1[] = { &#8220;Tsinghua &#8220;};<br \/>\nchar str2[] = { &#8220;Computer&#8221;};<br \/>\ncout &lt;&lt;strcpy(str1,str2)&lt;&lt;endl;<br \/>\n}<\/p>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1aTsinghua Computer<\/p>\n<p>\u6ce8\u610f\uff1a\u5728\u5b9a\u4e49\u5b57\u7b26\u6570\u7ec41\u7684\u957f\u5ea6\u65f6\u5e94\u8be5\u8003\u8651\u5b57\u7b26\u6570\u7ec42\u7684\u957f\u5ea6\uff0c\u56e0\u4e3a\u8fde\u63a5\u540e\u65b0\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u4e3a\u4e24\u4e2a\u5b57\u7b26\u4e32\u957f\u5ea6\u4e4b\u548c\u3002\u8fdb\u884c\u5b57\u7b26\u4e32\u8fde\u63a5\u540e\uff0c\u5b57\u7b26\u4e321\u7684\u7ed3\u5c3e\u7b26\u5c06\u81ea\u52a8\u88ab\u53bb\u6389\uff0c\u5728\u7ed3\u5c3e\u4e32\u672b\u5c3e\u4fdd\u7559\u65b0\u5b57\u7b26\u4e32\u540e\u9762\u4e00\u4e2a\u7ed3\u5c3e\u7b26\u3002<\/p>\n<p><strong>\u539f\u578b\uff1astrncat(char target[], const char source[], int numchars);<br \/>\n<\/strong>\u529f\u80fd\uff1a\u5c06\u5b57\u7b26\u4e32source\u7684\u524dnumchars\u4e2a\u5b57\u7b26\u63a5\u5230\u5b57\u7b26\u4e32target\u7684\u540e\u9762<br \/>\n\u4f8b\u7a0b\uff1a<\/p>\n<p>#include &lt;iostream.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\nvoid main(void)<br \/>\n{<br \/>\nchar str1[] = { &#8220;Tsinghua &#8220;};<br \/>\nchar str2[] = { &#8220;Computer&#8221;};<br \/>\ncout &lt;&lt;strncat(str1,str2,3)&lt;&lt;endl;<br \/>\n}<\/p>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1aTsinghua Com<\/p>\n<p><strong>\u539f\u578b\uff1aint strcmp(const char firststring[], const char secondstring);<br \/>\n<\/strong>\u529f\u80fd\uff1a\u6bd4\u8f83\u4e24\u4e2a\u5b57\u7b26\u4e32firststring\u548csecondstring<br \/>\n\u4f8b\u7a0b\uff1a<\/p>\n<p>#include &lt;iostream.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\nvoid main(void)<br \/>\n{<br \/>\nchar buf1[] = &#8220;aaa&#8221;;<br \/>\nchar buf2[] = &#8220;bbb&#8221;;<br \/>\nchar buf3[] = &#8220;ccc&#8221;;<br \/>\nint ptr;<br \/>\nptr = strcmp(buf2,buf1);<br \/>\nif(ptr &gt; 0)<br \/>\ncout &lt;&lt;&#8220;Buffer 2 is greater than buffer 1&#8243;&lt;&lt;endl;<br \/>\nelse<br \/>\ncout &lt;&lt;&#8220;Buffer 2 is less than buffer 1&#8243;&lt;&lt;endl;<br \/>\nptr = strcmp(buf2,buf3);<br \/>\nif(ptr &gt; 0)<br \/>\ncout &lt;&lt;&#8220;Buffer 2 is greater than buffer 3&#8243;&lt;&lt;endl;<br \/>\nelse<br \/>\ncout &lt;&lt;&#8220;Buffer 2 is less than buffer 3&#8243;&lt;&lt;endl;<br \/>\n}<\/p>\n<p>\u8fd0\u884c\u7ed3\u679c\u662f:Buffer 2 is less than buffer 1<br \/>\nBuffer 2 is greater than buffer 3<\/p>\n<p><strong>\u539f\u578b\uff1astrlen( const char string[] );<br \/>\n<\/strong>\u529f\u80fd\uff1a\u7edf\u8ba1\u5b57\u7b26\u4e32string\u4e2d\u5b57\u7b26\u7684\u4e2a\u6570<br \/>\n\u4f8b\u7a0b\uff1a<\/p>\n<p>#include &lt;iostream.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\nvoid main(void)<br \/>\n{<br \/>\nchar str[100];<br \/>\ncout &lt;&lt;&#8220;\u8bf7\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26\u4e32:&#8221;;<br \/>\ncin &gt;&gt;str;<br \/>\ncout &lt;&lt;&#8220;The length of the string is :&#8221;&lt;&lt;strlen(str)&lt;&lt;&#8220;\u4e2a&#8221;&lt;&lt;endl;<br \/>\n}<\/p>\n<p>\u8fd0\u884c\u7ed3\u679cThe length of the string is x (x\u4e3a\u4f60\u8f93\u5165\u7684\u5b57\u7b26\u603b\u6570\u5b57)<\/p>\n<p>\u6ce8\u610f\uff1astrlen\u51fd\u6570\u7684\u529f\u80fd\u662f\u8ba1\u7b97\u5b57\u7b26\u4e32\u7684\u5b9e\u9645\u957f\u5ea6\uff0c\u4e0d\u5305\u62ec&#8217;\\0&#8217;\u5728\u5185\u3002\u53e6\u5916\uff0cstrlen\u51fd\u6570\u4e5f\u53ef\u4ee5\u76f4\u63a5\u6d4b\u8bd5\u5b57\u7b26\u4e32\u5e38\u91cf\u7684\u957f\u5ea6\uff0c\u5982\uff1astrlen(&#8220;Welcome&#8221;)\u3002<\/p>\n<p><strong>void *memset(void *dest, int c, size_t count);<br \/>\n<\/strong>\u5c06dest\u524d\u9762count\u4e2a\u5b57\u7b26\u7f6e\u4e3a\u5b57\u7b26c.\u00a0 \u8fd4\u56dedest\u7684\u503c.<\/p>\n<p><strong>void *memmove(void *dest, const void *src, size_t count);<br \/>\n<\/strong>\u4ecesrc\u590d\u5236count\u5b57\u8282\u7684\u5b57\u7b26\u5230dest. \u5982\u679csrc\u548cdest\u51fa\u73b0\u91cd\u53e0, \u51fd\u6570\u4f1a\u81ea\u52a8\u5904\u7406.\u00a0 \u8fd4\u56dedest\u7684\u503c.<\/p>\n<p><strong>void *memcpy(void *dest, const void *src, size_t count);<br \/>\n<\/strong>\u4ecesrc\u590d\u5236count\u5b57\u8282\u7684\u5b57\u7b26\u5230dest. \u4e0ememmove\u529f\u80fd\u4e00\u6837, \u53ea\u662f\u4e0d\u80fd\u5904\u7406src\u548cdest\u51fa\u73b0\u91cd\u53e0.\u00a0 \u8fd4\u56dedest\u7684\u503c.<\/p>\n<p><strong>void *memchr(const void *buf, int c, size_t count);<br \/>\n<\/strong>\u5728buf\u524d\u9762count\u5b57\u8282\u4e2d\u67e5\u627e\u9996\u6b21\u51fa\u73b0\u5b57\u7b26c\u7684\u4f4d\u7f6e. \u627e\u5230\u4e86\u5b57\u7b26c\u6216\u8005\u5df2\u7ecf\u641c\u5bfb\u4e86count\u4e2a\u5b57\u8282, \u67e5\u627e\u5373\u505c\u6b62. \u64cd\u4f5c\u6210\u529f\u5219\u8fd4\u56debuf\u4e2d\u9996\u6b21\u51fa\u73b0c\u7684\u4f4d\u7f6e\u6307\u9488, \u5426\u5219\u8fd4\u56deNULL.<\/p>\n<p>void *_memccpy(void *dest, const void *src, int c, size_t count);<br \/>\n\u4ecesrc\u590d\u52360\u4e2a\u6216\u591a\u4e2a\u5b57\u8282\u7684\u5b57\u7b26\u5230dest. \u5f53\u5b57\u7b26c\u88ab\u590d\u5236\u6216\u8005count\u4e2a\u5b57\u7b26\u88ab\u590d\u5236\u65f6, \u590d\u5236\u505c\u6b62.<\/p>\n<p>\u5982\u679c\u5b57\u7b26c\u88ab\u590d\u5236, \u51fd\u6570\u8fd4\u56de\u8fd9\u4e2a\u5b57\u7b26\u540e\u9762\u7d27\u6328\u4e00\u4e2a\u5b57\u7b26\u4f4d\u7f6e\u7684\u6307\u9488. \u5426\u5219\u8fd4\u56deNULL.<\/p>\n<p><strong>int memcmp(const void *buf1, const void *buf2, size_t count);<br \/>\n<\/strong>\u6bd4\u8f83buf1\u548cbuf2\u524d\u9762count\u4e2a\u5b57\u8282\u5927\u5c0f.<br \/>\n\u8fd4\u56de\u503c&lt; 0, \u8868\u793abuf1\u5c0f\u4e8ebuf2;<br \/>\n\u8fd4\u56de\u503c\u4e3a0, \u8868\u793abuf1\u7b49\u4e8ebuf2;<br \/>\n\u8fd4\u56de\u503c&gt; 0, \u8868\u793abuf1\u5927\u4e8ebuf2.<\/p>\n<p><strong>int memicmp(const void *buf1, const void *buf2, size_t count);\u00a0<\/strong><\/p>\n<p>\u6bd4\u8f83buf1\u548cbuf2\u524d\u9762count\u4e2a\u5b57\u8282. \u4e0ememcmp\u4e0d\u540c\u7684\u662f, \u5b83\u4e0d\u533a\u5206\u5927\u5c0f\u5199.<\/p>\n<p>\u8fd4\u56de\u503c\u540c\u4e0a.<\/p>\n<p><strong>char *strrev(char *string);<br \/>\n<\/strong>\u5c06\u5b57\u7b26\u4e32string\u4e2d\u7684\u5b57\u7b26\u987a\u5e8f\u98a0\u5012\u8fc7\u6765. NULL\u7ed3\u675f\u7b26\u4f4d\u7f6e\u4e0d\u53d8.\u00a0 \u8fd4\u56de\u8c03\u6574\u540e\u7684\u5b57\u7b26\u4e32\u7684\u6307\u9488.<\/p>\n<p><strong>char *_strupr(char *string);<br \/>\n<\/strong>\u5c06string\u4e2d\u6240\u6709\u5c0f\u5199\u5b57\u6bcd\u66ff\u6362\u6210\u76f8\u5e94\u7684\u5927\u5199\u5b57\u6bcd, \u5176\u5b83\u5b57\u7b26\u4fdd\u6301\u4e0d\u53d8.\u00a0 \u8fd4\u56de\u8c03\u6574\u540e\u7684\u5b57\u7b26\u4e32\u7684\u6307\u9488.<\/p>\n<p><strong>char *_strlwr(char *string);<br \/>\n<\/strong>\u5c06string\u4e2d\u6240\u6709\u5927\u5199\u5b57\u6bcd\u66ff\u6362\u6210\u76f8\u5e94\u7684\u5c0f\u5199\u5b57\u6bcd, \u5176\u5b83\u5b57\u7b26\u4fdd\u6301\u4e0d\u53d8.\u00a0 \u8fd4\u56de\u8c03\u6574\u540e\u7684\u5b57\u7b26\u4e32\u7684\u6307\u9488.<\/p>\n<p><strong>char *strchr(const char *string, int c);<br \/>\n<\/strong>\u67e5\u627e\u5b57\u00a0 \u4e32string\u4e2d\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e, NULL\u7ed3\u675f\u7b26\u4e5f\u5305\u542b\u5728\u67e5\u627e\u4e2d.\u00a0 \u8fd4\u56de\u4e00\u4e2a\u6307\u9488, \u6307\u5411\u5b57\u7b26c\u5728\u5b57\u7b26\u4e32string\u4e2d\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e, \u5982\u679c\u6ca1\u6709\u627e\u5230, \u5219\u8fd4\u56deNULL.<\/p>\n<p><strong>char *strrchr(const char *string, int c);<br \/>\n<\/strong>\u67e5\u627e\u5b57\u7b26c\u5728\u5b57\u7b26\u4e32string\u4e2d\u6700\u540e\u4e00\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e, \u4e5f\u5c31\u662f\u5bf9string\u8fdb\u884c\u53cd\u5e8f\u641c\u7d22, \u5305\u542bNULL\u7ed3\u675f\u7b26.<br \/>\n\u8fd4\u56de\u4e00\u4e2a\u6307\u9488, \u6307\u5411\u5b57\u7b26c\u5728\u5b57\u7b26\u4e32string\u4e2d\u6700\u540e\u4e00\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e, \u5982\u679c\u6ca1\u6709\u627e\u5230, \u5219\u8fd4\u56deNULL.<\/p>\n<p><strong>char *strstr(const char *string, const char *strSearch);<br \/>\n<\/strong>\u5728\u5b57\u7b26\u4e32string\u4e2d\u67e5\u627estrSearch\u5b50\u4e32.\u00a0 \u8fd4\u56de\u5b50\u4e32strSearch\u5728string\u4e2d\u9996\u6b21\u51fa\u73b0\u4f4d\u7f6e\u7684\u6307\u9488. \u5982\u679c\u6ca1\u6709\u627e\u5230\u5b50\u4e32strSearch, \u5219\u8fd4\u56deNULL. \u5982\u679c\u5b50\u4e32strSearch\u4e3a\u7a7a\u4e32, \u51fd\u6570\u8fd4\u56destring\u503c.<\/p>\n<p><strong>char *strdup(const char *strSource);<br \/>\n<\/strong>\u51fd\u6570\u8fd0\u884c\u4e2d\u4f1a\u81ea\u5df1\u8c03\u7528malloc\u51fd\u6570\u4e3a\u590d\u5236strSource\u5b57\u7b26\u4e32\u5206\u914d\u5b58\u50a8\u7a7a\u95f4, \u7136\u540e\u518d\u5c06strSource\u590d\u5236\u5230\u5206\u914d\u5230\u7684\u7a7a\u95f4\u4e2d. \u6ce8\u610f\u8981\u53ca\u65f6\u91ca\u653e\u8fd9\u4e2a\u5206\u914d\u7684\u7a7a\u95f4.<br \/>\n\u8fd4\u56de\u4e00\u4e2a\u6307\u9488, \u6307\u5411\u4e3a\u590d\u5236\u5b57\u7b26\u4e32\u5206\u914d\u7684\u7a7a\u95f4; \u5982\u679c\u5206\u914d\u7a7a\u95f4\u5931\u8d25, \u5219\u8fd4\u56deNULL\u503c.<\/p>\n<p><strong>char *strcat(char *strDestination, const char *strSource);<br \/>\n<\/strong>\u5c06\u6e90\u4e32strSource\u6dfb\u52a0\u5230\u76ee\u6807\u4e32strDestination\u540e\u9762, \u5e76\u5728\u5f97\u5230\u7684\u65b0\u4e32\u540e\u9762\u52a0\u4e0aNULL\u7ed3\u675f\u7b26. \u6e90\u4e32strSource\u7684\u5b57\u7b26\u4f1a\u8986\u76d6\u76ee\u6807\u4e32strDestination\u540e\u9762\u7684\u7ed3\u675f\u7b26NULL. \u5728\u5b57\u7b26\u4e32\u7684\u590d\u5236\u6216\u6dfb\u52a0\u8fc7\u7a0b\u4e2d\u6ca1\u6709\u6ea2\u51fa\u68c0\u67e5, \u6240\u4ee5\u8981\u4fdd\u8bc1\u76ee\u6807\u4e32\u7a7a\u95f4\u8db3\u591f\u5927. \u4e0d\u80fd\u5904\u7406\u6e90\u4e32\u4e0e\u76ee\u6807\u4e32\u91cd\u53e0\u7684\u60c5\u51b5.\u00a0 \u51fd\u6570\u8fd4\u56destrDestination\u503c.<\/p>\n<p><strong>char *strncat(char *strDestination, const char *strSource, size_t count);<br \/>\n<\/strong>\u5c06\u6e90\u4e32strSource\u5f00\u59cb\u7684count\u4e2a\u5b57\u7b26\u6dfb\u52a0\u5230\u76ee\u6807\u4e32strDest\u540e. \u6e90\u4e32strSource\u7684\u5b57\u7b26\u4f1a\u8986\u76d6\u76ee\u6807\u4e32strDestination\u540e\u9762\u7684\u7ed3\u675f\u7b26NULL. \u5982\u679ccount\u5927\u4e8e\u6e90\u4e32\u957f\u5ea6, \u5219\u4f1a\u7528\u6e90\u4e32\u7684\u957f\u5ea6\u503c\u66ff\u6362count\u503c. \u5f97\u5230\u7684\u65b0\u4e32\u540e\u9762\u4f1a\u81ea\u52a8\u52a0\u4e0aNULL\u7ed3\u675f\u7b26. \u4e0estrcat\u51fd\u6570\u4e00\u6837, \u672c\u51fd\u6570\u4e0d\u80fd\u5904\u7406\u6e90\u4e32\u4e0e\u76ee\u6807\u4e32\u91cd\u53e0\u7684\u60c5\u51b5. \u51fd\u6570\u8fd4\u56destrDestination\u503c.<\/p>\n<p><strong>char *strcpy(char *strDestination, const char *strSource);<br \/>\n<\/strong>\u590d\u5236\u6e90\u4e32strSource\u5230\u76ee\u6807\u4e32strDestination\u6240\u6307\u5b9a\u7684\u4f4d\u7f6e, \u5305\u542bNULL\u7ed3\u675f\u7b26. \u4e0d\u80fd\u5904\u7406\u6e90\u4e32\u4e0e\u76ee\u6807\u4e32\u91cd\u53e0\u7684\u60c5\u51b5.\u51fd\u6570\u8fd4\u56destrDestination\u503c.<\/p>\n<p><strong>char *strncpy(char *strDestination, const char *strSource, size_t count);<\/strong><br \/>\n\u5c06\u6e90\u4e32strSource\u5f00\u59cb\u7684count\u4e2a\u5b57\u7b26\u590d\u5236\u5230\u76ee\u6807\u4e32strDestination\u6240\u6307\u5b9a\u7684\u4f4d\u7f6e. \u5982\u679ccount\u503c\u5c0f\u4e8e\u6216\u7b49\u4e8estrSource\u4e32\u7684\u957f\u5ea6, \u4e0d\u4f1a\u81ea\u52a8\u6dfb\u52a0NULL\u7ed3\u675f\u7b26\u76ee\u6807\u4e32\u4e2d, \u800ccount\u5927\u4e8estrSource\u4e32\u7684\u957f\u5ea6\u65f6, \u5219\u5c06strSource\u7528NULL\u7ed3\u675f\u7b26\u586b\u5145\u8865\u9f50count\u4e2a\u5b57\u7b26, \u590d\u5236\u5230\u76ee\u6807\u4e32\u4e2d. \u4e0d\u80fd\u5904\u7406\u6e90\u4e32\u4e0e\u76ee\u6807\u4e32\u91cd\u53e0\u7684\u60c5\u51b5.\u51fd\u6570\u8fd4\u56destrDestination\u503c.<\/p>\n<p><strong>char *strset(char *string, int c);<br \/>\n<\/strong>\u5c06string\u4e32\u7684\u6240\u6709\u5b57\u7b26\u8bbe\u7f6e\u4e3a\u5b57\u7b26c, \u9047\u5230NULL\u7ed3\u675f\u7b26\u505c\u6b62. \u51fd\u6570\u8fd4\u56de\u5185\u5bb9\u8c03\u6574\u540e\u7684string\u6307\u9488.<\/p>\n<p><strong>char *strnset(char *string, int c, size_t count);<br \/>\n<\/strong>\u5c06string\u4e32\u5f00\u59cbcount\u4e2a\u5b57\u7b26\u8bbe\u7f6e\u4e3a\u5b57\u7b26c, \u5982\u679ccount\u503c\u5927\u4e8estring\u4e32\u7684\u957f\u5ea6, \u5c06\u7528string\u7684\u957f\u5ea6\u66ff\u6362count\u503c. \u51fd\u6570\u8fd4\u56de\u5185\u5bb9\u8c03\u6574\u540e\u7684string\u6307\u9488.<\/p>\n<p><strong>size_t strspn(const char *string, const char *strCharSet);<br \/>\n<\/strong>\u67e5\u627e\u4efb\u4f55\u4e00\u4e2a\u4e0d\u5305\u542b\u5728strCharSet\u4e32\u4e2d\u7684\u5b57\u7b26 (\u5b57\u7b26\u4e32\u7ed3\u675f\u7b26NULL\u9664\u5916) \u5728string\u4e32\u4e2d\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e\u5e8f\u53f7.\u00a0 \u8fd4\u56de\u4e00\u4e2a\u6574\u6570\u503c, \u6307\u5b9a\u5728string\u4e2d\u5168\u90e8\u7531characters\u4e2d\u7684\u5b57\u7b26\u7ec4\u6210\u7684\u5b50\u4e32\u7684\u957f\u5ea6. \u5982\u679cstring\u4ee5\u4e00\u4e2a\u4e0d\u5305\u542b\u5728strCharSet\u4e2d\u7684\u5b57\u7b26\u5f00\u5934, \u51fd\u6570\u5c06\u8fd4\u56de0\u503c.<\/p>\n<p><strong>size_t strcspn(const char *string, const char *strCharSet);<br \/>\n<\/strong>\u67e5\u627estrCharSet\u4e32\u4e2d\u4efb\u4f55\u4e00\u4e2a\u5b57\u7b26\u5728string\u4e32\u4e2d\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e\u5e8f\u53f7, \u5305\u542b\u5b57\u7b26\u4e32\u7ed3\u675f\u7b26NULL.<br \/>\n\u8fd4\u56de\u4e00\u4e2a\u6574\u6570\u503c, \u6307\u5b9a\u5728string\u4e2d\u5168\u90e8\u7531\u975echaracters\u4e2d\u7684\u5b57\u7b26\u7ec4\u6210\u7684\u5b50\u4e32\u7684\u957f\u5ea6. \u5982\u679cstring\u4ee5\u4e00\u4e2a\u5305\u542b\u5728strCharSet\u4e2d\u7684\u5b57\u7b26\u5f00\u5934, \u51fd\u6570\u5c06\u8fd4\u56de0\u503c.<\/p>\n<p><strong>char *strspnp(const char *string, const char *strCharSet);<br \/>\n<\/strong>\u67e5\u627e\u4efb\u4f55\u4e00\u4e2a\u4e0d\u5305\u542b\u5728strCharSet\u4e32\u4e2d\u7684\u5b57\u7b26 (\u5b57\u7b26\u4e32\u7ed3\u675f\u7b26NULL\u9664\u5916) \u5728string\u4e32\u4e2d\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e\u6307\u9488. \u8fd4\u56de\u4e00\u4e2a\u6307\u9488, \u6307\u5411\u975estrCharSet\u4e2d\u7684\u5b57\u7b26\u5728string\u4e2d\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e.<\/p>\n<p><strong>char *strpbrk(const char *string, const char *strCharSet);<\/strong><br \/>\n\u67e5\u627estrCharSet\u4e32\u4e2d\u4efb\u4f55\u4e00\u4e2a\u5b57\u7b26\u5728string\u4e32\u4e2d\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e, \u4e0d\u5305\u542b\u5b57\u7b26\u4e32\u7ed3\u675f\u7b26NULL.<br \/>\n\u8fd4\u56de\u4e00\u4e2a\u6307\u9488, \u6307\u5411strCharSet\u4e2d\u4efb\u4e00\u5b57\u7b26\u5728string\u4e2d\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e. \u5982\u679c\u4e24\u4e2a\u5b57\u7b26\u4e32\u53c2\u6570\u4e0d\u542b\u76f8\u540c\u5b57\u7b26, \u5219\u8fd4\u56deNULL\u503c.<\/p>\n<p><strong>int strcmp(const char *string1, const char *string2);<br \/>\n<\/strong>\u6bd4\u8f83\u5b57\u7b26\u4e32string1\u548cstring2\u5927\u5c0f.<br \/>\n\u8fd4\u56de\u503c&lt; 0, \u8868\u793astring1\u5c0f\u4e8estring2;<br \/>\n\u8fd4\u56de\u503c\u4e3a0, \u8868\u793astring1\u7b49\u4e8estring2;<br \/>\n\u8fd4\u56de\u503c&gt; 0, \u8868\u793astring1\u5927\u4e8estring2.<\/p>\n<p><strong>int stricmp(const char *string1, const char *string2);<br \/>\n<\/strong>\u6bd4\u8f83\u5b57\u7b26\u4e32string1\u548cstring2\u5927\u5c0f\uff0c\u548cstrcmp\u4e0d\u540c, \u6bd4\u8f83\u7684\u662f\u5b83\u4eec\u7684\u5c0f\u5199\u5b57\u6bcd\u7248\u672c.\u8fd4\u56de\u503c\u4e0estrcmp\u76f8\u540c.<\/p>\n<p><strong>int strcmpi(const char *string1, const char *string2);<br \/>\n<\/strong>\u7b49\u4ef7\u4e8estricmp\u51fd\u6570, \u53ea\u662f\u63d0\u4f9b\u4e00\u4e2a\u5411\u540e\u517c\u5bb9\u7684\u7248\u672c.<\/p>\n<p><strong>int strncmp(const char *string1, const char *string2, size_t count);<br \/>\n<\/strong>\u6bd4\u8f83\u5b57\u7b26\u4e32string1\u548cstring2\u5927\u5c0f\uff0c\u53ea\u6bd4\u8f83\u524d\u9762count\u4e2a\u5b57\u7b26. \u6bd4\u8f83\u8fc7\u7a0b\u4e2d, \u4efb\u4f55\u4e00\u4e2a\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u5c0f\u4e8ecount, \u5219count\u5c06\u88ab\u8f83\u77ed\u7684\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u53d6\u4ee3. \u6b64\u65f6\u5982\u679c\u4e24\u4e32\u524d\u9762\u7684\u5b57\u7b26\u90fd\u76f8\u7b49, \u5219\u8f83\u77ed\u7684\u4e32\u8981\u5c0f.<br \/>\n\u8fd4\u56de\u503c&lt; 0, \u8868\u793astring1\u7684\u5b50\u4e32\u5c0f\u4e8estring2\u7684\u5b50\u4e32;<br \/>\n\u8fd4\u56de\u503c\u4e3a0, \u8868\u793astring1\u7684\u5b50\u4e32\u7b49\u4e8estring2\u7684\u5b50\u4e32;<br \/>\n\u8fd4\u56de\u503c&gt; 0, \u8868\u793astring1\u7684\u5b50\u4e32\u5927\u4e8estring2\u7684\u5b50\u4e32.<\/p>\n<p><strong>int strnicmp(const char *string1, const char *string2, size_t count);<br \/>\n<\/strong>\u6bd4\u8f83\u5b57\u7b26\u4e32string1\u548cstring2\u5927\u5c0f\uff0c\u53ea\u6bd4\u8f83\u524d\u9762count\u4e2a\u5b57\u7b26. \u4e0estrncmp\u4e0d\u540c\u7684\u662f, \u6bd4\u8f83\u7684\u662f\u5b83\u4eec\u7684\u5c0f\u5199\u5b57\u6bcd\u7248\u672c.\u00a0 \u8fd4\u56de\u503c\u4e0estrncmp\u76f8\u540c.<\/p>\n<p><strong>char *strtok(char *strToken, const char *strDelimit);<br \/>\n<\/strong>\u5728strToken \u4e32\u4e2d\u67e5\u627e\u4e0b\u4e00\u4e2a\u6807\u8bb0, strDelimit\u5b57\u7b26\u96c6\u5219\u6307\u5b9a\u4e86\u5728\u5f53\u524d\u67e5\u627e\u8c03\u7528\u4e2d\u53ef\u80fd\u9047\u5230\u7684\u5206\u754c\u7b26. \u8fd4\u56de\u4e00\u4e2a\u6307\u9488, \u6307\u5411\u5728strToken\u4e2d\u627e\u5230\u7684\u4e0b\u4e00\u4e2a\u6807\u8bb0. \u5982\u679c\u627e\u4e0d\u5230\u6807\u8bb0, \u5c31\u8fd4\u56deNULL\u503c. \u6bcf\u6b21\u8c03\u7528\u90fd\u4f1a\u4fee\u6539strToken\u5185\u5bb9, \u7528NULL\u5b57\u7b26\u66ff\u6362\u9047\u5230\u7684\u6bcf\u4e2a\u5206\u754c\u7b26.<\/p>\n<p><strong>c++\u6982\u5ff5\u5b57\u7b26\u4e32\u64cd\u4f5c\u00a0<\/strong><\/p>\n<p><strong>\u4e00\u3001char_traits \u5b57\u7b26\u7279\u5f81\u7c7b<br \/>\n<\/strong>1\uff09\u610f\u4e49\uff1a\u5305\u88c5\u7279\u5b9a\u4e32\u5143\u7d20\u7684\u901a\u7528\u884c\u4e3a\u754c\u9762\uff0c\u4ee5\u4fbf\u5bb9\u5668\u5b9e\u73b0\u65f6\u4f9d\u636e\u7279\u5f81\u4fe1\u606f\u800c\u6267\u884c\u7279\u5b9a\u884c\u4e3a<br \/>\n2\uff09\u5b9a\u4e49\u4e86\u901a\u7528\u7c7b\u578b\u540d<\/p>\n<p>typedef _Elem char_type;<br \/>\ntypedef int int_type;<br \/>\ntypedef streampos pos_type;<br \/>\ntypedef streamoff off_type;<br \/>\ntypedef mbstate_t state_type;<\/p>\n<p>\u5176\u4e2d int_type \u8868\u793a\u5b57\u7b26\u5143\u7d20\u8f6c\u6362\u5230\u7279\u5b9a\u7f16\u7801\u65f6\u7684\u6574\u578b\u8868\u793a\uff0cpos_type, off_type \u5206\u522b\u4f5c\u4e3a\u5b57\u7b26\u4e32\u7d22\u5f15\u548c\u5b57\u7b26\u4e32\u5143\u7d20\u504f\u79fb\u7684\u7c7b\u578b\uff0c\u7c7b\u4f3c\u5bb9\u5668\u8fed\u4e2d\u7684\u6307\u9488\uff0c\u8fed\u4ee3\u7c7b\u578b\u548c\u6307\u9488\uff0c\u8fed\u4ee3\u5668\u7684\u504f\u79fb\u7c7b\u578b\u3002\u6700\u540e\u7684 state_type \u7528\u4e8e\u5b58\u50a8\u6d41\u72b6\u6001\uff0c\u5982\u51fa\u9519\uff0c\u683c\u5f0f\u63a7\u5236\u7b49\u7b49\u3002<\/p>\n<p>3\uff09\u5b9a\u4e49\u4e86\u5b57\u7b26 \/ \u5b57\u7b26\u4e32\u64cd\u4f5c\u7684\u5305\u88c5\u754c\u9762\uff0c\u4ee5\u4fbf\u901a\u7528\u7b97\u6cd5\u7684\u8c03\u7528<\/p>\n<p>assign(a, b) \u5b9a\u4e49\u5c06 b \u5b57\u7b26\u8d4b\u503c\u7ed9 a \u5b57\u7b26\u7684\u8fc7\u7a0b\uff0c\u5b9e\u73b0 a.operator = \u7684\u884c\u4e3a<br \/>\neq(a, b) \u5b9a\u4e49 a \u5b57\u7b26\u548c b \u5b57\u7b26\u7684\u76f8\u7b49\u5173\u7cfb\uff0c\u5b9e\u73b0 a.operator == \u7684\u884c\u4e3a<br \/>\nlt(a, b) \u5b9a\u4e49 a \u5c0f\u4e8e b \u7684\u5173\u7cfb\uff0c\u5b9e\u73b0 a.operator &lt; \u7684\u884c\u4e3a<br \/>\ncompare(a_ptr, b_ptr, cnt) \u5b9a\u4e49\u4e24\u7ec4\u5b57\u7b26\u4e32\u7684\u6bd4\u8f83\uff0c\u8fd4\u56de int \u7c7b\u578b\uff0c\u5b9e\u73b0\u7c7b\u4f3c memcmp \u7684\u884c\u4e3a<br \/>\nlength(ptr) \u5b9a\u4e49\u53d6\u5b57\u7b26\u4e32\u957f\u5ea6\uff0c\u5b9e\u73b0\u7c7b\u4f3c strlen \u7684\u884c\u4e3a<br \/>\ncopy(a_ptr, b_ptr, cnt) \u5b9a\u4e49\u4e24\u7ec4\u5b57\u7b26\u4e32\u7684\u590d\u5236\uff0c\u5b9e\u73b0\u7c7b\u4f3c memcpy \u7684\u884c\u4e3a<br \/>\nmove(a_ptr, b_ptr, cnt) \u5b9a\u4e49\u4e24\u7ec4\u5b57\u7b26\u4e32\u7684\u4e0d\u91cd\u53e0\u590d\u5236\uff0c\u5b9e\u73b0\u7c7b\u4f3c memmove \u7684\u884c\u4e3a<br \/>\nassign(ptr, cnt, ch) \u5b9a\u4e49\u4e86\u586b\u5145\u5b57\u7b26\u4e32\u7684\u8fc7\u7a0b\uff0c\u5b9e\u73b0\u7c7b\u4f3c memset \u7684\u884c\u4e3a<br \/>\nto_int_type(ch) \u5b9a\u4e49\u4e86 char_type \u5230 int_type \u6574\u578b\u7684\u8f6c\u6362\u8fc7\u7a0b<br \/>\nto_char_type(n) \u5b9a\u4e49\u4e86 int_type \u5230 char_type \u5b57\u7b26\u578b\u7684\u8f6c\u6362\u8fc7\u7a0b<br \/>\neq_int_type(a, b) \u5b9a\u4e49\u4e24\u4e2a\u548c\u5f53\u524d char_type \u7c7b\u578b\u5bf9\u5e94\u7684 int_type \u7684\u76f8\u7b49\u5173\u7cfb<br \/>\neof() \u5b9a\u4e49\u5b57\u7b26\u4e32\u7ed3\u5c3e\u7b26\uff0c\u4f7f\u7528\u6574\u578b\u8868\u793a<br \/>\nnot_eof(n) \u5b9a\u4e49\u975e\u5b57\u7b26\u4e32\u7ed3\u5c3e\u7b26\uff0c\u82e5\u8f93\u5165\u7ed3\u5c3e\u7b26\uff0c\u5219\u8fd4\u56de 1\uff0c\u5176\u4ed6\u8f93\u5165\u8fd4\u56de\u539f\u503c\uff0c\u5373\u603b\u662f\u4e0d\u8fd4\u56de eof()<\/p>\n<p>4\uff09int_type \u7c7b\u578b\u5e94\u662f\u5f53\u524d\u5b57\u7b26\u7c7b\u578b\u7684\u6574\u578b\u7f16\u7801<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u4e8c\u3001std::string \u5e76\u4e0d\u662f\u5e8f\u5217\u5bb9\u5668<\/strong>\uff0c\u6ca1\u6709 front() \u548c back() \u754c\u9762\u7528\u4e8e\u53d6\u51fa\u524d\u7aef\u548c\u5c3e\u7aef\u7684\u5143\u7d20\uff0c\u4f7f\u7528 std::string::operator [] \u5e76\u4f20\u9012 streampos \u7c7b\u578b\u53d6\u5f97\u7279\u5b9a\u5143\u7d20\uff0c\u5982 std::string::size() &#8211; 1 \u4f5c\u4e3a\u7d22\u5f15\u53d6\u5f97\u6700\u540e\u4e00\u4e2a\u5b57\u7b26<\/p>\n<p><strong>\u4e09\u3001basic_string \u652f\u6301\u7684\u521d\u59cb\u5316<br \/>\n<\/strong>1\uff09\u9ed8\u8ba4\u521d\u59cb\u5316<br \/>\n2\uff09\u5206\u914d\u5668<br \/>\n3\uff09\u590d\u5236\u6784\u9020<br \/>\n4\uff09\u5c40\u90e8\u590d\u5236 [_Roff, _Roff + _Count)<br \/>\n5\uff09\u5c40\u90e8\u590d\u5236 + \u5206\u914d\u5668<br \/>\n6\uff09C \u5b57\u7b26\u4e32 [_Ptr, &lt;null&gt;)<br \/>\n7\uff09C \u5b57\u7b26\u4e32 + _Count [_Ptr, _Ptr + _Count)<br \/>\n8\uff09C \u5b57\u7b26\u4e32 + \u5206\u914d\u5668<br \/>\n9\uff09C \u5b57\u7b26\u4e32 + _Count + \u5206\u914d\u5668 [_Ptr, _Ptr + _Count)<\/p>\n<p>10\uff09_Count * _Ch<br \/>\n11\uff09_Count * _Ch + \u5206\u914d\u5668<br \/>\n12\uff09\u8fed\u4ee3\u5668 [_ItF, _ItL)<br \/>\n13\uff09\u8fed\u4ee3\u5668 + \u5206\u914d\u5668<\/p>\n<p>\u5b57\u7b26\u5230\u4e32\u4e0d\u80fd\u521d\u59cb\u5316\uff0c\u4f46\u652f\u6301 operator = \u8d4b\u503c\u548c operator += \u7d2f\u52a0\u8d4b\u503c\u8fd0\u7b97\u3002<\/p>\n<p><strong>\u56db\u3001\u5b57\u7b26\u4e32\u7684\u533a\u95f4\u6709\u6548\u6027<br \/>\n<\/strong>\u5bf9\u4e32\u7684\u7d22\u5f15\u8bbf\u95ee\u5728\u8d85\u8fc7\u5b57\u7b26\u4e32\u7684\u6709\u6548\u533a\u95f4\u65f6\uff0c\u56e0\u4e3a\u4e32\u7684\u5728\u5b9e\u73b0\u4e0a\u5bf9\u5185\u7f6e\u7684\u5b57\u7b26\u7f13\u51b2\u533a\u6267\u884c\u4e0b\u6807\u8bbf\u95ee\uff0c\u6240\u4ee5\u4e0d\u4f1a\u5bfc\u81f4\u5f02\u5e38\uff0c\u4f46\u662f\u5c06\u5f97\u5230\u4e0d\u53ef\u9884\u77e5\u7684\u7ed3\u679c\uff0c\u901a\u5e38\u662f\u4e0d\u53ef\u7528\u7684\u3002<br \/>\n\u5c06\u5176\u4ed6\u5b57\u7b26\u4e32\u4f5c\u4e3a\u53f3\u503c\u8f93\u5165\u65f6\uff0c\u5bf9\u8be5\u4e32\u53d6\u51fa\u8ba1\u6570\u5927\u4e8e\u4e32\u5927\u5c0f\u65f6\u6309\u4e32\u5927\u5c0f\u8ba1\u7b97\u3002<br \/>\nstd::basic_string::size_type \u7684\u5b9e\u9645\u7c7b\u578b\u4e3a size_t\uff0c\u5728 Visual C++ 7.1 \u4e2d\u5b9e\u73b0\u4e3a unsigned\uff0cstd::basic_string::npos \u88ab\u9759\u6001\u8bbe\u5b9a\u4e3a<\/p>\n<p>(basic_string&lt;_Elem, _Traits, _Alloc&gt;::size_type)(-1);<\/p>\n<p>\u5728\u67e5\u627e\u5b50\u5b57\u7b26\u4e32\u7b49\u64cd\u4f5c\u65f6\uff0c\u51fd\u6570\u8fd4\u56de npos \u7684\u503c\u8868\u793a\u975e\u6cd5\u7d22\u5f15\u3002<\/p>\n<p><strong>\u4e94\u3001\u6bd4\u8f83\u5b57\u7b26\u4e32<br \/>\n<\/strong>\u5141\u8bb8\u7684\u6bd4\u8f83\u5bf9\u8c61<br \/>\n1\uff09compare(s2) \u5176\u4ed6\u540c\u7c7b\u578b\u5b57\u7b26\u4e32<br \/>\n2\uff09compare(p) C \u98ce\u683c\u5b57\u7b26\u4e32<br \/>\n3\uff09compare(off, cnt, s2) [off, off + cnt) \u540c s2 \u6267\u884c\u6bd4\u8f83<br \/>\n4\uff09compare(off, cnt, s2, off2, cnt2) [off, off + cnt) \u540c s2 [off2, cnt2) \u6267\u884c\u6bd4\u8f83<br \/>\n5\uff09compare(off, cnt, p) [off, off + cnt) \u540c [p , &lt;null&gt;) \u6267\u884c\u6bd4\u8f83<br \/>\n6\uff09compare(off, cnt, p, cnt2) [off, off + cnt) \u540c [p, p + cnt2) \u6267\u884c\u6bd4\u8f83<\/p>\n<p>\u8fd4\u56de -1, 0, 1 \u4f5c\u4e3a\u5c0f\u4e8e\u3001\u7b49\u4e8e\u548c\u5927\u4e8e\u7684\u6bd4\u8f83\u7ed3\u679c\u3002<\/p>\n<p><strong>\u00a0\u516d\u3001\u9644\u52a0\u6570\u636e<br \/>\n<\/strong>1\uff09\u4f7f\u7528 operator += \u63a5\u53d7\u5176\u4ed6\u5b57\u7b26\u4e32\uff0cC \u98ce\u683c\u5b57\u7b26\u4e32\u548c\u5b57\u7b26<br \/>\n2\uff09\u4f7f\u7528 push_back() \u5728\u5c3e\u90e8\u9644\u52a0\u5b57\u7b26\uff0c\u5e76\u4f7f\u5f97\u901a\u8fc7\u5b57\u7b26\u4e32\u6784\u9020\u7684 back_iterator \u53ef\u4ee5\u8bbf\u95ee<br \/>\n3\uff09append() \u9644\u52a0<br \/>\n1\u3001append(s) \u8ffd\u52a0\u5b57\u7b26\u4e32<br \/>\n2\u3001append(s, off, cnt) \u8ffd\u52a0\u5b57\u7b26\u4e32 s [off, off + cnt)<br \/>\n3\u3001append(p) \u8ffd\u52a0\u5b57\u7b26\u4e32 [p, &lt;null&gt;)<br \/>\n4\u3001append(p, cnt) \u8ffd\u52a0\u5b57\u7b26\u4e32 [p, p + cnt)<br \/>\n5\u3001append(n, c) \u586b\u5145 n * c<br \/>\n6\u3001append(InF, InL) \u8ffd\u52a0\u8f93\u5165\u6d41 [InF, InL)<\/p>\n<p>4\uff09insert() \u63d2\u5165<br \/>\n1\u3001insert(off, s2) \u63d2\u5165\u5b57\u7b26\u4e32<br \/>\n2\u3001insert(off, s2, off2, cnt2) \u63d2\u5165\u5b57\u7b26\u4e32 s [off2, off2 + cnt2)<br \/>\n3\u3001insert(off, p) \u63d2\u5165\u5b57\u7b26\u4e32 [p, &lt;null&gt;)<br \/>\n4\u3001insert(off, p, cnt) \u63d2\u5165\u5b57\u7b26\u4e32 [p, p + cnt)<\/p>\n<p>5\u3001insert(off, n, c) \u63d2\u5165 n * c<br \/>\n6\u3001insert(iter) \u5143\u7d20\u9ed8\u8ba4\u503c\u586b\u5145<br \/>\n7\u3001insert(iter, c) \u63d2\u5165\u7279\u5b9a\u5143\u7d20<br \/>\n8\u3001insert(iter, n, c) \u63d2\u5165 n*c<br \/>\n9\u3001insert(iter, InF, InL) \u63d2\u5165 [InF, InL)<\/p>\n<p>5\uff09operator +(a, b)<br \/>\n\u5b57\u7b26\u4e32\u5173\u8054\u8fd0\u7b97\u7b26\u91cd\u8f7d\u4e2d\u652f\u6301 operator + \u7684\u5f62\u5f0f<br \/>\n1\u3001s + s<br \/>\n2\u3001s + p<br \/>\n3\u3001s + c<br \/>\n4\u3001p + s<br \/>\n5\u3001c + s<\/p>\n<p><strong>\u4e03\u3001\u67e5\u627e\u3001\u66ff\u6362\u548c\u6e05\u9664<br \/>\n<\/strong>1\uff09find() \u67e5\u627e<br \/>\n1\u3001find(c, off) \u5728 s [off, npos) \u4e2d\u67e5\u627e c<br \/>\n2\u3001find(p, off, n) \u5728 s [off, npos) \u4e2d\u67e5\u627e [p, p + n)<br \/>\n3\u3001find(p, off) \u5728 s [off, npos) \u4e2d\u67e5\u627e [p, &lt;null&gt;)<br \/>\n4\u3001find(s2, off) \u5728 s [off, npos) \u4e2d\u67e5\u627e s2<\/p>\n<p>2\uff09find() \u7684\u53d8\u79cd<br \/>\n1\u3001rfind() \u5177\u6709 find() \u7684\u8f93\u5165\u5f62\u5f0f\uff0c\u53cd\u5e8f\u67e5\u627e<br \/>\n2\u3001find_first_of() \u5177\u6709 find() \u7684\u8f93\u5165\u5f62\u5f0f\uff0c\u8fd4\u56de\u7b2c\u4e00\u4e2a\u5339\u914d\u7684\u7d22\u5f15<br \/>\n3\u3001find_last_of() \u5177\u6709 find() \u7684\u8f93\u5165\u5f62\u5f0f\uff0c\u8fd4\u56de\u5012\u6570\u7b2c\u4e00\u4e2a\u5339\u914d\u7684\u7d22\u5f15<br \/>\n4\u3001find_first_not_of() \u5177\u6709 find() \u7684\u8f93\u5165\u5f62\u5f0f\uff0c\u8fd4\u56de\u7b2c\u4e00\u4e2a\u4e0d\u5339\u914d\u7684\u7d22\u5f15<br \/>\n5\u3001find_last_not_of() \u5177\u6709 find() \u7684\u8f93\u5165\u5f62\u5f0f\uff0c\u8fd4\u56de\u5012\u6570\u7b2c\u4e00\u4e2a\u4e0d\u5339\u914d\u7684\u7d22\u5f15<\/p>\n<p>3\uff09replace() \u66ff\u6362<br \/>\n1\u3001replace(off, cnt, s2) \u5c06 s [off, off + cnt) \u66ff\u6362\u6210 s2<br \/>\n2\u3001replace(off, cnt, s2, off2, cnt2) \u5c06 s [off, off + cnt) \u66ff\u6362\u6210 s2 [off2, off2 + cnt2)<br \/>\n3\u3001replace(off, cnt, p) \u5c06 s [off, off + cnt) \u66ff\u6362\u6210 [p, &lt;null&gt;)<br \/>\n4\u3001replace(off, cnt, p, cnt2) \u5c06 s [off, off + cnt) \u66ff\u6362\u6210 [p, p + cnt2)<\/p>\n<p>5\u3001replace(off, cnt, n, c) \u5c06 s [off, off + cnt) \u66ff\u6362\u6210 c * n<\/p>\n<p>\u4f7f\u7528\u8fed\u4ee3\u5668\u7684\u60c5\u51b5\uff1a<br \/>\n6\u3001replace(InF, InL, s2) \u5c06 [InF, InL) \u66ff\u6362\u6210 s2<br \/>\n7\u3001replace(InF, InL, p) \u5c06 [InF, InL) \u66ff\u6362\u6210 [p, &lt;null&gt;)<br \/>\n8\u3001replace(InF, InL, p, cnt) \u5c06 [InF, InL) \u66ff\u6362\u6210 [p, p + cnt)<br \/>\n9\u3001replace(InF, InL, n, c) \u5c06 [InF, InL) \u66ff\u6362\u6210 n * c<br \/>\n10\u3001replace(InF, InL, InF2, InL2) \u5c06 [InF, InL) \u66ff\u6362\u6210 [InF2, InL2)<\/p>\n<p>4\uff09erase() \u5220\u9664<br \/>\n1\u3001erase(off, cnt) \u4ece\u5b57\u7b26\u4e32 s \u4e2d\u5220\u9664 s [off, off + cnt)<br \/>\n2\u3001erase(iter) \u4ece\u5b57\u7b26\u4e32 s \u4e2d\u5220\u9664 *iter<br \/>\n3\u3001erase(ItF, ItL) \u4ece\u5b57\u7b26\u4e32 s \u4e2d\u5220\u9664 [ItF, ItL)<\/p>\n<p><strong>\u516b\u3001\u53d6\u51fa\u5b57\u7b26\u4e32<br \/>\n<\/strong>1\uff09\u53d6\u5f97 C \u98ce\u683c\u5b57\u7b26\u4e32<br \/>\nc_str() \u8fd4\u56de\u5e38\u91cf\u7c7b\u578b\u7684 C \u98ce\u683c\u5b57\u7b26\u4e32\u6307\u9488\uff0ccopy(ptr, cnt, off = 0) \u5219\u5c06\u6307\u5b9a\u5927\u5c0f\u7684\u5b57\u7b26\u4e32\u590d\u5236\u5230\u7279\u5b9a\u6307\u9488\u3002data() \u5728 Visual C++ 7.1 \u4e2d\u4ec5\u4ec5\u8c03\u7528\u4e86 c_str() \u5b9e\u73b0\u3002<br \/>\n2\uff09\u53d6\u5f97\u5b50\u5b57\u7b26\u4e32<br \/>\nsubstr(off, cnt) \u53d6\u5f97 s [off, off + cnt) \u7684\u526f\u672c\u3002<br \/>\n3\uff09\u590d\u5236\u5b50\u5b57\u7b26\u4e32<br \/>\ncopy(p, off, cnt) \u5c06 s [off, off + cnt) \u590d\u5236\u5230 p\u3002<\/p>\n<p><strong>\u4e5d\u3001\u5b57\u7b26\u4e32\u7684\u7f13\u51b2\u533a\u7ba1\u7406<br \/>\n<\/strong>\u5b57\u7b26\u4e32\u5177\u6709\u7c7b\u4f3c std::vector \u7684\u7f13\u51b2\u533a\u7ba1\u7406\u754c\u9762\u3002<br \/>\nsize() \u53d6\u5f97\u6709\u6548\u5143\u7d20\u957f\u5ea6<br \/>\nmax_size() \u53d6\u5f97\u5f53\u524d\u5185\u5b58\u5206\u914d\u5668\u80fd\u5206\u914d\u7684\u6709\u6548\u7a7a\u95f4<br \/>\nreserve() \u4e3a\u7f13\u51b2\u533a\u9884\u7559\u7a7a\u95f4<br \/>\ncapacity() \u53d6\u5f97\u7f13\u51b2\u533a\u7684\u5bb9\u91cf<br \/>\nresize() \u91cd\u8bbe\u4e32\u7684\u957f\u5ea6\uff0c\u53ef\u4ee5\u4e3a\u5176\u6307\u5b9a\u521d\u59cb\u5316\u503c<\/p>\n<p><strong>\u00a0 \u5341\u3001\u5b9a\u4e49\u8f93\u5165\u8fed\u4ee3\u5668\u7684\u5c3e\u7aef<br \/>\n<\/strong>\u5411 istream_iterator \u4f20\u9012\u8f93\u5165\u6d41\u5bf9\u8c61\u4ee5\u521b\u5efa\u8f93\u5165\u8fed\u4ee3\u5668\uff0c\u8f93\u5165\u8fed\u4ee3\u5668\u6301\u6709\u8f93\u5165\u6d41\u5bf9\u8c61\u7684\u6307\u9488\uff0c\u9ed8\u8ba4\u521b\u5efa\u548c\u8bfb\u53d6\u6d41\u5931\u8d25\u7684\u60c5\u51b5\u4e0b\u8be5\u6307\u9488\u88ab\u8bbe\u7f6e\u4e3a 0\u3002\u5e76\u4e14\u5728\u5b9e\u73b0\u8f93\u5165\u8fed\u4ee3\u5668\u95f4\u7684 operator == \u76f8\u7b49\u8fd0\u7b97\u65f6\uff0c\u8fdb\u884c\u6301\u6709\u7684\u6d41\u5bf9\u8c61\u6307\u9488\u7684\u76f8\u7b49\u6bd4\u8f83\uff0c\u8fd9\u6837\uff0c\u9ed8\u8ba4\u521b\u5efa\u7684\u8f93\u5165\u8fed\u4ee3\u5668\u5c06\u88ab\u7528\u4e8e\u5339\u914d\u8f93\u5165\u6d41\u7684\u7ed3\u675f\u3002<\/p>\n<p>* \u5f53\u8f93\u5165\u6d41\u8bfb\u53d6\u5931\u8d25\uff0c\u7528\u6237\u6267\u884c if, while \u6761\u4ef6\u5224\u65ad\u65f6\uff0c\u5b9e\u9645\u4e0a\u5148\u5c06\u5224\u65ad\u503c\u8f6c\u6362\u6210 void* \u7c7b\u578b\uff0c\u6216\u8005\u6839\u636e operator ! \u8fd0\u7b97\u7b26\u7684\u8fd4\u56de\u7ed3\u679c\uff0c\u5bf9\u8f93\u5165\u6d41\u91cd\u8f7d operator void* \u548c operator ! \u8fd0\u7b97\u7b26\uff0c\u53ef\u4ee5\u5b9a\u4e49\u8f93\u5165\u6d41\u5728\u5e03\u5c14\u8868\u8fbe\u5f0f\u4e2d\u7684\u884c\u4e3a\uff0c\u4f7f\u5f97\u5f53\u6d41\u8bfb\u53d6\u5931\u8d25\u7684\u60c5\u51b5\u4e0b\uff0c\u8f93\u5165\u8fed\u4ee3\u5668\u53ef\u4ee5\u901a\u8fc7\u5e03\u5c14\u8868\u8fbe\u5f0f\u6765\u786e\u8ba4\uff0c\u800c\u4e0d\u662f\u663e\u5f0f\u8bbf\u95ee fail() \u6210\u5458\u51fd\u6570.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"slide-text-bg2\">\n<h3>1\uff09\u5b57\u7b26\u4e32\u64cd\u4f5c strcpy(p, p1<\/h3>\n<\/div>\n<div class=\"flex-btn-div\"><a href=\"http:\/\/www.recologypower.com:9080\/?p=128\" class=\"btn1 flex-btn\">\u9605\u8bfb\u66f4\u591a<\/a><\/div>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"_links":{"self":[{"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/posts\/128"}],"collection":[{"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=128"}],"version-history":[{"count":1,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/posts\/128\/revisions"}],"predecessor-version":[{"id":129,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=\/wp\/v2\/posts\/128\/revisions\/129"}],"wp:attachment":[{"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=128"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.recologypower.com:9080\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}