| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2536 人关注过本帖
标题:str.GetBuffer(0)???
只看楼主 加入收藏
喜鹊王子
Rank: 1
等 级:新手上路
帖 子:105
专家分:0
注 册:2012-12-25
结帖率:89.74%
收藏
已结贴  问题点数:5 回复次数:3 
str.GetBuffer(0)???
图片附件: 游客没有浏览图片的权限,请 登录注册
   
CString Port;
GetDlgItemText(IDC_EDIT_PORT_LOCAL,Port);//“端口”编辑框的ID为IDC_EDIT_PORT_LOCAL
m_nPortLocal=atoi(Port.GetBuffer(0));
if(m_nPortLocal<0||m_nPortLocal>65535)
{
   AfxMessageBox("请输入正确的端口!");
   return;
}

标红的那一句话怎么理解啊?Port.GetBuffer(0)返回的到底是什么东东?
搜索更多相关主题的帖子: return 编辑 
2013-03-25 21:38
yuccn
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:何方
等 级:版主
威 望:167
帖 子:6815
专家分:42393
注 册:2010-12-16
收藏
得分:5 
要学会用msdn啊,那么大的一笔财富不用,太浪费了


CString::GetBuffer
 Returns a pointer to the internal character buffer for the CSimpleStringT object.
 
nMinBufferLength
 The minimum size of the character buffer in characters. This value does not include space for a null terminator.

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2013-03-25 22:17
喜鹊王子
Rank: 1
等 级:新手上路
帖 子:105
专家分:0
注 册:2012-12-25
收藏
得分:0 
回复 2楼 yuccn
这里为什么不直接写:
m_nPortLocal=atoi(Port);

路漫漫其修远兮,吾将上下而求索。
2013-03-25 22:29
yuccn
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:何方
等 级:版主
威 望:167
帖 子:6815
专家分:42393
注 册:2010-12-16
收藏
得分:0 
因为Port 是CString,是一个对象而
atoi 函数原型是 支持char *的,不一样的参数,怎么能够这样写?

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2013-03-25 22:43
快速回复:str.GetBuffer(0)???
数据加载中...
 
   



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

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