70,023
社区成员




#include<stdio.h>
#include<string.h>
int main()
{
char* s="current time at \\test 10-1-2009 1:1 PM";
char* p;
p=strchr(s,'-');
while(*p!=' ')p--;
printf("%s\n",p);
getch();
return 0;
}
#include<iostream>
#include<string>
using namespace std;
int main()
{
string s="current time at \\test 1-1-2009 1:1 PM";
char res[100];
sscanf(s.c_str(),"%*[^\\]\\%*[^ ] %[^\0]",res);
cout<<res;
return EXIT_SUCCESS;
}
// 先找第一个空格,然后拷贝后面的字符串到缓存区中
TCHAR *pStr = _T("\\test 1-1-2009 1:1 PM");
TCHAR szDate[32] = { 0 };
TCHAR *p = _tcschr(pStr, _T(' '));
if (p && ++p)
{
_tcscpy(szDate, p);
}