| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 424 人关注过本帖
标题:请教关于CString
只看楼主 加入收藏
MQKt
Rank: 2
等 级:论坛游民
帖 子:235
专家分:20
注 册:2006-6-29
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:5 
请教关于CString
在LIST BOX控件中读到一行文字,文字规律是 “文字+两个空格+文字+两个空格+文字+两个空格+数值”
请教如何得到这个数值?
搜索更多相关主题的帖子: 如何 
2011-05-18 08:40
yuccn
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:何方
等 级:版主
威 望:167
帖 子:6815
专家分:42393
注 册:2010-12-16
收藏
得分:5 
查下MSDN中的CString,里面的成员函数应该能满足你的要求的,

[ 本帖最后由 yuccn 于 2011-5-18 09:25 编辑 ]

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2011-05-18 09:08
MQKt
Rank: 2
等 级:论坛游民
帖 子:235
专家分:20
注 册:2006-6-29
收藏
得分:0 
就是没MSDN咯,记得的只有一个find,right,left,GetLength

2011-05-18 09:11
yuccn
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:何方
等 级:版主
威 望:167
帖 子:6815
专家分:42393
注 册:2010-12-16
收藏
得分:0 
能上网也行了啊,到微软官方的MSDN去查就行了

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2011-05-18 09:25
yuccn
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:何方
等 级:版主
威 望:167
帖 子:6815
专家分:42393
注 册:2010-12-16
收藏
得分:5 
CString::Format
void Format( LPCTSTR lpszFormat, ... );

void Format( UINT nFormatID, ... );

Parameters

lpszFormat

A format-control string.

nFormatID

The string resource identifier that contains the format-control string.

Remarks

Call this member function to write formatted data to a CString in the same way that sprintf formats data into a C-style character array. This function formats and stores a series of characters and values in the CString. Each optional argument (if any) is converted and output according to the corresponding format specification in lpszFormat or from the string resource identified by nFormatID.

The call will fail if the string object itself is offered as a parameter to Format. For example, the following code:

CString str = "Some Data";
str.Format("%s%d", str, 123);   // Attention: str is also used in the parameter list.

will cause unpredictable results.

When you pass a character string as an optional argument, you must cast it explicitly as LPCTSTR. The format has the same form and function as the format argument for the printf function. (For a description of the format and arguments, seeprintf in the Run-Time Library Reference.) A null character is appended to the end of the characters written.

For more information, seesprintf in the Run-Time Library Reference.

Example

CString str;

str.Format(_T("Floating point: %.2f\n"), 12345.12345);
_tprintf("%s", (LPCTSTR) str);

str.Format(_T("Left-justified integer: %.6d\n"), 35);
_tprintf("%s", (LPCTSTR) str);

str.Format(IDS_SCORE, 5, 3);
_tprintf("%s", (LPCTSTR) str);
   

Output

If the application has a string resource with the identifier IDS_SCORE that contains the string "Penguins: %d\nFlyers  : %d\n", the above code fragment produces this output:

Floating point: 12345.12
Left-justified integer: 000035
Penguins: 5
Flyers  : 3

msdn上烤过来的

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2011-05-18 09:29
MQKt
Rank: 2
等 级:论坛游民
帖 子:235
专家分:20
注 册:2006-6-29
收藏
得分:0 
下载了一个,谢谢

2011-05-18 09:39
快速回复:请教关于CString
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020850 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved