怎么去除一个字符串左边的几个字符,不用CString的delete方法
如何去除一个字符串左边的几个字符,不用CString的delete方法
比如一个字符串\??\c:\1.txt,用一般的字符串函数如何删除\??\,不用CString
------解决方案--------------------
strcpy(sz,sz+4);
------解决方案--------------------
char szOK[]="\\??\\c:\\1.txt";
char szCmp[]="\\??\\";
cout<<szOK<<endl;
char* szF=strstr(szOK,szCmp);
strcpy(szOK,szF+strlen(szCmp)-1);
cout<<szF<<endl;
------解决方案--------------------
char szOK[]="1\\??\\c:\\1.txt";
char szCmp[]="\\??\\";
cout<<szOK<<endl;
char* szF=strstr(szOK,szCmp);
int nF=szF-szOK;
strcpy(szOK+nF,szF+strlen(szCmp)-1);
cout<<szOK<<endl;
这个是删除,其余的保留
比如一个字符串\??\c:\1.txt,用一般的字符串函数如何删除\??\,不用CString
------解决方案--------------------
strcpy(sz,sz+4);
------解决方案--------------------
char szOK[]="\\??\\c:\\1.txt";
char szCmp[]="\\??\\";
cout<<szOK<<endl;
char* szF=strstr(szOK,szCmp);
strcpy(szOK,szF+strlen(szCmp)-1);
cout<<szF<<endl;
------解决方案--------------------
char szOK[]="1\\??\\c:\\1.txt";
char szCmp[]="\\??\\";
cout<<szOK<<endl;
char* szF=strstr(szOK,szCmp);
int nF=szF-szOK;
strcpy(szOK+nF,szF+strlen(szCmp)-1);
cout<<szOK<<endl;
这个是删除,其余的保留