-
Driving me crazy
i have this problem for over a week now..
How do i then search the AdapterName array..
get to get each individual set of characters that make a string.
i am using this method
and the application just crashes upon load
Code:
/////////////////////////////////////////////////////////////////////////
char AdapterName[8192];
char *temp,*temp1;
//AdapterName char array gets populated by
if(PacketGetAdapterNames(AdapterName,&AdapterLength)==FALSE)
{
cout << "Unable to detect the network adapters installed on this box!\n";
return -1;
}
temp=AdapterName;
temp1=AdapterName;
while ((*temp!='\0')||(*(temp-1)!='\0'))
{
if (*temp=='\0')
{
strncpy(AdapterList[i],temp1,(temp-temp1)*2);
temp1=temp+1;
i++;
}
temp++; //Incrementing Original char Pointer
}
if anyone could help me out it would be really appreciated
[code][/code]tagged by Salem
-
I don't think you wanted to do this in the while condition
(*(temp-1)!='\0')
i'm not sure that the -1 is right
-
Sorry OS is win2k..
so chars are stored in unicode..
can u tell me which struct or type
i should be storing unicode chars in ?
-
ok i will do that thank you..
but is the logic in my loop flawed do u know?
the end result of myloop
is i want to be able to say characterArray[3]
and it points the position of the starting string of characters stored there
-
-
well, it may be becaues you are using the logical OR operator(||) in the loop's conditional statement. Both (*temp!='\0') and
(*(temp-1)!='\0') would have to be false. That might be the problem. I would try using AND (&&) instead of OR, or taking out the second part of that conditional completely.