?? subject_41198.htm
字號:
<p>
序號:41198 發表者:Rikcuo Akira 發表日期:2003-05-24 23:11:25
<br>主題:印出左邊起兩個字元
<br>內容:char str[]={"abcd"};<BR><BR>印出左邊起兩個字元,"ab"<BR>要用哪一個函數<BR><BR>PS:就如VB的Left<BR><BR>
<br><a href="javascript:history.go(-1)">返回上頁</a><br><a href=http://www.copathway.com/cndevforum/>訪問論壇</a></p>
<hr size=1>
<blockquote><p>
回復者:dr0 回復日期:2003-05-24 23:13:07
<br>內容:strlen
<br>
<a href="javascript:history.go(-1)">返回上頁</a><br><a href=http://www.copathway.com/cndevforum/>訪問論壇</a></p></blockquote>
<hr size=1>
<blockquote><p>
回復者:dr0 回復日期:2003-05-24 23:14:08
<br>內容:多查查MSDN, 要是像你這個問法,寫個程序要發一萬張貼子
<br>
<a href="javascript:history.go(-1)">返回上頁</a><br><a href=http://www.copathway.com/cndevforum/>訪問論壇</a></p></blockquote>
<hr size=1>
<blockquote><p>
回復者:Rikcuo Akira 回復日期:2003-05-25 04:20:20
<br>內容:可不可以給我一個方向去找,因為我找過沒有才發問的.<BR>
<br>
<a href="javascript:history.go(-1)">返回上頁</a><br><a href=http://www.copathway.com/cndevforum/>訪問論壇</a></p></blockquote>
<hr size=1>
<blockquote><p>
回復者:dr0 回復日期:2003-05-25 12:36:14
<br>內容: char *s; // 假設你的string是s指向的字符串<BR> <BR> int index; // index 是你要得到的sub-string的長度,no NULL terminated<BR> <BR> assert(index <= strlen(s)); // 主意子串的長度要小與s的長度 <BR> char *b = (char *)malloc(index + 1);<BR><BR> while (*s && index) {<BR> *b++ = *s++; index--<BR> }<BR><BR> *b = '\0'; // SET terminated NULL
<br>
<a href="javascript:history.go(-1)">返回上頁</a><br><a href=http://www.copathway.com/cndevforum/>訪問論壇</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回復者:dr0 回復日期:2003-05-25 12:42:50
<br>內容:/*++<BR><BR>name: strleft<BR>param:<BR> IN const char *s, source string address<BR> IN OUT char *b, buffer to contain the sub-string<BR> IN int size, the size of sub-string<BR>return:<BR> buffer b<BR><BR>--*/<BR><BR>char *strleft(const char *s, char *b, int size)<BR>{<BR> assert(size);<BR> assert(strlen(s)>=size);<BR><BR> while (*s && size) {<BR> *b++ = *s++; size--<BR> }<BR> *b = '\0'; <BR> return b;<BR>}<BR>2003-5-25 12:46:44
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -