使用字符串搜索函数,找到空格位置,然后使用取字串函数
int Find(
PCXSTR pszSub,
int iStart=0);
int Find(
PCXSTR pszSub,
int iStart=0);
解决方案 »
- 如何将对话框中的鼠标设置为大十字线并显示当前坐标
- 各位帮忙看看哪里出错了? 数据库操作
- 既ON_CONTROL_RANGE 又单独 会怎么样
- 为何用CString::Format函数无法将char*转换CString?
- 如何得到CDC设备的范围大小?
- 关于CreateProcess()的一个问题
- 请问vc中如何设置窗口的大小和位置(不是对话框)?
- 哪里有《COM原理与应用》下载呀!
- 全局变量CSocket g_listen由线程A creat,bind,listen,由线程B accept,一定要在线程A处Detach,线程B处Attach吗?为什么<vc技术内幕>里的ex34a不用这样做也行?
- 请教大侠!!!!急。。。。。。。。。。。。。
- CFile的奇怪问题,在线等
- 一个简单的问题 关于md5 急
str="1001 AAAAA";
int nSlash=str.Find(" ");
if(nSlash!=-1)
{
strLeft=str.Left(nSlash);
strRight=str.Right(nSlash+1);
}
这样
CString str,strLeft,strRight;
str="1001 AAAAA";
int nSlash=str.Find(" ");
if(nSlash!=-1)
{
strLeft=str.Left(nSlash);
strRight=str.MId(nSlash+1);
}
CString arrItem[2];
int i=strItem.Find(' ');
arrItem[0]=strItem.Left(i);
arrItem[1]=strItem.Right(i+1);
int strName_length=m_str.GetLength();
int position1=PT_Table.m_strName.Find(' ');
if(position1!=-1)
{
int position2=m_str.Find(' ',position1+1);
int position3=m_str.Find(' ',position2+1);
int position4=m_strName.Find(' ',position3+1);
CString str1,str2,str3,str4,str5;
str1=m_str.Left(position1);
str2=m_str.Mid(position1+1,position2-position1-1);
str3=m_str.Mid(position2+1,position3-position2-1);
str4=m_str.Mid(position3+1,position4-position3-1);
str5=m_strRight(strName_length-position4-1);
then U CAN CONVERT CSTRING TO CHAR*
maybe +2 not +1
maybe something wrong with +1 and -1.u try it.
在msdn中仔细的将CString类的函数看一遍,包你会做了
#include <strstream>
using namespace std;int main() {
istrstream s("1001 AAAAA");
char a[20],b[20];
s >> a >> b; // Whitespace-delimited input
cout << " s1 = " << a << endl;
cout << " s2 = " << b << endl; return 0;大家认为这样写可以吗?