I have login name like domain\username, I tried to use strtok to parse it. However, strtok can not recognize "\". For example,
char ustring[] = "domain\username";
sLogin = strtok(ustring, "\\" );
sDomain = sLogin;
while( sLogin != NULL )
{
sUser = sLogin;
sLogin = strtok( NULL, "\\" );
}
Output both sDomain and sUser are domainusername
However, if I change ustring to the following by adding one more "\"
char ustring[] = "domain\\username";
it will parse the login correctly like
sDomain: domain
sUser: username
So any idea how to add one more backslash into login name
Thanks in advance.

parse the login name
RBrady
seems there is some problem to post the source code, here it is
for (i=0; i<strlen(sLogin); i++){
if(sLogin
!= char(92)&& bDomain == false ){
sDomain=sLogin
;
}
else{
bDomain == true;
sUser[j]=sLogin
;
}
}
vinothr
oops, again
for (i=0; i<strlen(sLogin); i++){
if(sLogin[ i ] != char(92)&& bDomain == false ){
sDomain[ i ]=sLogin[ i ];
}
else{
bDomain == true;
sUser[ j ]=sLogin[ i ] ;
}
}
Lexite
Oshah, Thanks for the reply. login info is entered in user interface and it is passed in as the parameter. when login parameter char array gets it, it will be like "domain\user". so I have to change it to "domain\\user". But I do not know how to do it. I even think about the following, but it is not working
for (i=0; i<strlen(sLogin)+1; i++){ if(sLoginsDomain
=sLogin
;
} else{bDomain == true;
sUser[j]=sLogin
;
}
Genja_Eugeny
A2324_1
I think you didn't get what OShah meant. \\ translates to \. Your input string needs to have two slashes - which get treated as a single slash.
KimberlyL
As you know "domain\\username"; translates to domain\username once compiled.
Your logic is correct... it's just the input string that's wrong. When you change ustring so that it comes from the user or external source, your code will parse it correctly.