📄 subject_34272.htm
字号:
<p>
序号:34272 发表者:n 发表日期:2003-03-28 10:24:05
<br>主题:一个关于string的控制台程序的问题
<br>内容:#include <iostream.h><BR>#include <string><BR><BR>void main()<BR>{<BR> string strName;<BR> strName = "ni hao";<BR> cout << strName << endl;<BR>}<BR>为什么编译出错啊,换成<BR>#include <Afx.h><BR>#include <iostream.h><BR>#include <string><BR><BR>void main()<BR>{<BR> CString strName;<BR> strName = "ni hao";<BR> cout << strName << endl;<BR>}<BR>可以编译,但不能生成.exe<BR>为什么啊,还要引用lib吗?<BR>关于string,vc里的是不是有什么额外的规定解释什么的啊?<BR>CString和string是怎么回事啊?
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:steele 回复日期:2003-03-28 10:40:33
<br>内容:用char* string="ni hao";<BR> cout<<string<<endl;换掉下面的代码<BR> string strName;<BR> strName = "ni hao";<BR> cout << strName << endl;<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>
回复者:n 回复日期:2003-04-09 06:31:53
<br>内容:你那里面的string和我说的string不是一回事吧
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:neilgan 回复日期:2003-04-09 09:22:05
<br>内容:For the first segment of the source code: add "using namespace std;" after you include <string>, but I don't know why cout doesn't support string, I have no experience using "string". If you know how to let cout support string, please let me know.<BR><BR>For the second one, go to project->setting->general, set "using MFC as a shared dll" or "using MFC as a static lib".<BR><BR>string is a feature of standard C++, CString is a part of MFC. So you need to add MFC support in your project for the second source code.<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>回复者:neilgan 回复日期:2003-04-10 22:35:28
<br>内容:#include <iostream><BR>#include <string><BR><BR>using namespace std;<BR><BR>void main()<BR>{<BR> string msg="Hello, World!";<BR> cout << msg << endl;<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>
回复者:lijianxu 回复日期:2003-04-11 09:22:20
<br>内容:#include <iostream.h><BR>#include <string><BR>using namespace std;<BR>void main()<BR>{<BR> char *strName = "ni hao";<BR> cout<<strName<<endl;<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 + -