⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_40516.htm

📁 vc
💻 HTM
字号:
<p>
序号:40516 发表者:rayjoe 发表日期:2003-05-19 14:40:55
<br>主题:请问如何提取string变量中的一部分从而生成新的string变量?
<br>内容:<BR>&nbsp;&nbsp; 比如我有一个字符串:<BR>&nbsp;&nbsp; string oringialword("cpp_example_0519_first");<BR>&nbsp;&nbsp; string newword;<BR><BR>&nbsp;&nbsp; 如何将第一个string 中的0519提取出来,赋值给<BR>&nbsp;&nbsp; 第二个string呢?<BR><BR>&nbsp;&nbsp;谢谢
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:RealMan 回复日期:2003-05-19 16:10:20
<br>内容:it is very easy, u can use this <BR><BR>CString newword = oringialword.Mid(12, 4);<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>
回复者:rayjoe 回复日期:2003-05-19 17:40:45
<br>内容:如果不是用mfc呢?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:RealMan 回复日期:2003-05-19 18:25:42
<br>内容:u can do like this:)<BR>int iNum;<BR>iNum = atoi(oringialword);<BR>char *newword = new char[256];<BR>itoa(iNum, newword, 10);<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>
<font color=red>答案被接受</font><br>回复者:哎哟 回复日期:2003-05-29 08:36:04
<br>内容:代码如下,为简单起见,没有作边界检测。<BR>#include &lt;iostream&gt;<BR>#include &lt;functional&gt;<BR>#include &lt;algorithm&gt;<BR>#include &lt;string&gt;<BR>#include &lt;ctype.h&gt;<BR><BR>using namespace std;<BR><BR>int main()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;string oringialword("cpp_example_0519_first");<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;string::iterator iter=<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;find_if(oringialword.begin(),oringialword.end(),ptr_fun(isdigit));<BR>&nbsp;&nbsp;&nbsp;&nbsp;string::iterator iter1=<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;find_if(iter,oringialword.end(),not1(ptr_fun(isdigit)));<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;string newword(iter,iter1);<BR>&nbsp;&nbsp;&nbsp;&nbsp;cout&lt;&lt;newword&lt;&lt;endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp;return 0;<BR>}<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -