64,683
社区成员
发帖
与我相关
我的任务
分享
char* extract(const char *source, int index, char splitterchar, int &len)
{
len = 0;
const char *rc = source;
while (1)
{
rc = source;
if (!index)
break;
while ((splitterchar != *source) && (0 != *source))
source++;
while ((splitterchar == *source) && (0 != *source))
source++;
index--;
if (0 == *source)
return NULL;
}
if (0 == index)
{
const char *t = rc;
while ((splitterchar != *t) && (0 != *t))
{
len++;
t++;
}
}
return (char*)rc;
}
for(long m = 0; m < 1000000; m++)
{
temp.TrimLeft();
for(int i = num - 1; i > 0; i--)
{
int index = temp.Find(' ');
temp = temp.Right(temp.GetLength() - index - 1);
temp.TrimLeft();
}
temp = temp.Left(temp.Find(' '));
}
cout << "end" << endl;
CString m_str = "aaaa bbbbbbbb ccccc ddddddddd eeeeeeee";
int num;
cin >> num; // 你的p_iIdx参数
CString temp = m_str; // 你的p_pString
temp.TrimLeft();
for(int i = num - 1; i > 0; i--)
{
int index = temp.Find(' ');
temp = temp.Right(temp.GetLength() - index - 1);
temp.TrimLeft();
}
temp = temp.Left(temp.Find(' '));
cout << (LPCTSTR)temp << endl;