how to use string class in visual c++

0 views
Skip to first unread message

MYL

unread,
Jul 11, 2007, 1:39:43 PM7/11/07
to Visual C++ Lovers
I just start using visual c++. Am struggling how to use string class
in visual c++ 6. Seems the compiler does not recognize this C++
standard class.

Even the following code can't compile. Can anyone give suggestion?

#include <string.h>

String str="ok '";
str.append("ok");

ronghui

unread,
Jul 11, 2007, 8:50:36 PM7/11/07
to Visual-...@googlegroups.com

You should add using namespace std; after #include <string.h>
#include <string.h>
using namespace std;

String str="ok '";
str.append("ok");

-----邮件原件-----
发件人: Visual-...@googlegroups.com
[mailto:Visual-...@googlegroups.com] 代表 MYL
发送时间: 2007年7月12日 星期四 1:40
收件人: Visual C++ Lovers
主题: [Visual-C-Lovers] how to use string class in visual c++

#include <string.h>

----------------------------------------------------------------------------------------------
Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s) is intended only for the use of the intended recipient and may be confidential and/or privileged of Neusoft Group Ltd., its subsidiaries and/or its affiliates. If any reader of this communication is not the intended recipient, unauthorized use, forwarding, printing, storing, disclosure or copying is strictly prohibited, and may be unlawful. If you have received this communication in error, please immediately notify the sender by return e-mail, and delete the original message and all copies from your system. Thank you.
-----------------------------------------------------------------------------------------------

Joe

unread,
Jul 13, 2007, 2:42:54 AM7/13/07
to Visual C++ Lovers
Use CString instead. In VC++ all the string functions are replaced in
the class CString. Also as far as i know no need to #include
<string.h> i think. MFC will remeber that automatically.
Reply all
Reply to author
Forward
0 new messages