看:
bool Initstr(char *Dest[],char *Sour)
{
char *temp=Sour;
for(int i=0;i<MAX_VALUE;i++)\\MAX_VALUE为文件名数
{
while((*Dest[i]++ = *temp++) != ','
&& *temp != '\0')
{
if(*temp == '\\')
*Dest[i]++ = '\\';
}
if(*temp == '\0')break;
}
return TRUE;
}
函数判断了字符串最后一个字符不为“,”的情况,假如那位高手有更有水平的代码,可以互相讨论
bool Initstr(char *Dest[],char *Sour)
{
char *temp=Sour;
for(int i=0;i<MAX_VALUE;i++)\\MAX_VALUE为文件名数
{
while((*Dest[i]++ = *temp++) != ','
&& *temp != '\0')
{
if(*temp == '\\')
*Dest[i]++ = '\\';
}
if(*temp == '\0')break;
}
return TRUE;
}
函数判断了字符串最后一个字符不为“,”的情况,假如那位高手有更有水平的代码,可以互相讨论
bool Initstr(char *Dest[],char *Sour)
{
char *temp=Sour;
for(int i=0;i<MAX_VALUE;i++)\\MAX_VALUE为文件名数
{
while((*Dest[i]++ = *temp++) != ','
&& *temp != '\0')
{
if(*temp == '\\')
*Dest[i]++ = '\\';
}
if(*temp == '\0')break;
}
return TRUE;
}
函数判断了字符串最后一个字符不为“,”的情况,假如那位高手有更有水平的代码,可以互相讨论
#include <stdio.h>char string[]= "c:\mydir\file1.txt,d:\mydir\fi.txt,d:\dkg\ffff.exe,c:\dhgk\sdjgi.dll,";
char seps[] = ",";
char *token;void main( void )
{
printf( "%s\n\nTokens:\n", string );
/* Establish string and get the first token: */
token = strtok( string, seps );
while( token != NULL )
{
/* While there are tokens in "string" */
printf( " %s\n", token );
/* Get next token: */
token = strtok( NULL, seps );
}
}
测试上面已通过注意到了,打印出来的没了'\',好办。再用CString::Repleace()把每个子串中的'\\'替换为'\\\'自己试吧,已经很简单了。
{
//AfxMessageBox("good");
TCHAR a;
TCHAR b;
for (int j=0;j<tt.GetLength();j++)
{
a=tt.GetAt(j);
if (a<(0x00))
{
j=j+1;
b=tt.GetAt(j);
if(b>0x00)
{
if(b=0x27)
{ // '=0x2
tt.SetAt(j-1,0x20) ;
}
}
}
}
// AfxMessageBox(tt);
return tt;
}
这个是我以前对数据导入时半个中文字符的处理函数,应该对你有帮助
{
CString temp = mystring;
cstring temp1;
cstringarray arraystring;
unsigned int t = temp.GetLength();
for ( unsigned int i = 0 ; i< t ;i++ )
{ if(temp[i] != '\')
temp1 +=temp[i];
else
{
temp1+='\';
temp1+='\';
arraystring.add(temp1);
}}
return arraystring;
}思路就这样了,你自己改吧。
{
int i = 0
char *sep = ",";
char *p = strtok(src, sep);
while( p!= NULL ) {
MyStrCpy(dest[i], p);
p = strtok( NULL, sep);
++ i;
}
}
void MyStrCpy(char *dest, char *src)
{
int i = 0;
char p[100];
char* s = src;
while(*s) {
if (*s != '\\')
p[i] = *s;
else
p[i] = *s; ++ i; p[i] = *s;
++ i;
}
p[i] = '\0';
dest = strdup(p);
}
谢谢大家,给分!!