Like under:
CString strOrg;
strOrg="1/2/33/4/5/6";
I wanna output:
1
2
33
4
5
6
and it's better to split the string into a string array
for your help,there are a "thanks" only
CString strOrg;
strOrg="1/2/33/4/5/6";
I wanna output:
1
2
33
4
5
6
and it's better to split the string into a string array
for your help,there are a "thanks" only
解决方案 »
- VS2010 MDI程序中调用SetMenu(AfxGetApp()->m_pMainWnd->m_hWnd, m_hMDIMenu)动态设置主框架菜单的问题
- vs2010,界面编辑模式下第三方控件(TeeChart)不停的自我刷新,怎么回事?
- 想监控程序界面,如何实现在在屏幕锁定下抓屏?
- 如何发现局域网内其它机器
- 如何实现发送邮件的功能?
- 怎么做个文件共享
- 请问如何显示出一个提示对话框,让用户选择是与否
- 关于目录、文件的问题,请关注
- 请教一个IE临时文件夹的问题
- 麻烦介绍几个国外的类似与csdn这样提问/借大的网站????
- dll中高手:如何在钩到一个鼠标按下或释放消息后,发送同样的消息回主窗口。
- 关于支持多个双接口的问题,编译通过,但使用时对两个接口调用不同函数,结果却一样???(有源码)
CString a[MaxNum];
CString strOrg,strTemp,str;
strOrg="1/2/33/4/5/6";
int n=strTemp.Find(_T('//'));
int i=0;
while(n!=-1)
{
a[i++]=strTemp.Left(n);
str=strTemp.Right(strTemp.GetLength()-n-1);
strTemp=str;
n=strTemp.Find(_T('//'));
}
strtok
that's good
#include <iostream.h> int nBegin=0, nEnd;
CStringArray strAry;
char subStr[20];
char org[100] = ("1/2/33/4/5/6");
CString strOrg(org);
do
{
nEnd = strOrg.Find('/', nBegin);
if ( -1 != nEnd )
{
memcpy(subStr, org+nBegin, nEnd);
subStr[nEnd-nBegin] = '\0';
CString temp(subStr);
strAry.Add(temp);
nBegin = nEnd+1;
}
}while (-1 != nEnd ); int nCount = strAry.GetSize();
for (int i=0; i<nCount; ++i)
{
cout << (LPCTSTR)strAry.GetAt(i) << endl;
}
Find the next token in a string.char *strtok( char *strToken, const char *strDelimit );wchar_t *wcstok( wchar_t *strToken, const wchar_t *strDelimit );unsigned char *_mbstok( unsigned char*strToken, const unsigned char *strDelimit );
#include <stdio.h>
#include <windows.h>
#include <iostream.h>
char seps[]="/";
char *token;void main( void )
{
char string1[]="1/2/33/4/5/6"; printf( "%s\n\nTokens:\n", string );
token = strtok( string, seps );
while( token != NULL )
{
cout<<token;
token = strtok( NULL, seps );
}
cout<<buff;
}你只要先把你的CString转换成char*类型就OK了