﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-乔栋的佛国</title><link>http://www.cppblog.com/qiaodong/</link><description>耶路撒冷对你来说意味着什么？</description><language>zh-cn</language><lastBuildDate>Sat, 16 May 2026 08:21:36 GMT</lastBuildDate><pubDate>Sat, 16 May 2026 08:21:36 GMT</pubDate><ttl>60</ttl><item><title>Cstring and char *</title><link>http://www.cppblog.com/qiaodong/archive/2007/08/03/29310.html</link><dc:creator>乔栋</dc:creator><author>乔栋</author><pubDate>Fri, 03 Aug 2007 09:05:00 GMT</pubDate><guid>http://www.cppblog.com/qiaodong/archive/2007/08/03/29310.html</guid><wfw:comment>http://www.cppblog.com/qiaodong/comments/29310.html</wfw:comment><comments>http://www.cppblog.com/qiaodong/archive/2007/08/03/29310.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qiaodong/comments/commentRss/29310.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qiaodong/services/trackbacks/29310.html</trackback:ping><description><![CDATA[char*转换成CString &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 若将char*转换成CString，除了直接赋值外，还可使用CString::format进行。例如： &nbsp; <br>&nbsp; char &nbsp; chArray[] &nbsp; = &nbsp; "This &nbsp; is &nbsp; a &nbsp; test"; &nbsp; <br>&nbsp; char &nbsp; * &nbsp; p &nbsp; = &nbsp; "This &nbsp; is &nbsp; a &nbsp; test"; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 或 &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; LPSTR &nbsp; p &nbsp; = &nbsp; "This &nbsp; is &nbsp; a &nbsp; test"; &nbsp; 或在已定义Unicode应的用程序中 &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; TCHAR &nbsp; * &nbsp; p &nbsp; = &nbsp; _T("This &nbsp; is &nbsp; a &nbsp; test"); &nbsp; 或 &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; LPTSTR &nbsp; p &nbsp; = &nbsp; _T("This &nbsp; is &nbsp; a &nbsp; test"); &nbsp; <br>&nbsp; CString &nbsp; theString &nbsp; = &nbsp; chArray; &nbsp; <br>&nbsp; theString.format(_T("%s"), &nbsp; chArray); &nbsp; <br>&nbsp; theString &nbsp; = &nbsp; p; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 2、CString转换成char* &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 若将CString类转换成char*(LPSTR)类型，常常使用下列三种方法： &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 方法一，使用强制转换。例如： &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; CString &nbsp; theString( &nbsp; "This &nbsp; is &nbsp; a &nbsp; test" &nbsp; ); &