I have a buffer formated as a list of strings delimited by null character. I am trying to use strtok to tokenize or parse this buffer into seperate strings.

the formate of the buffer is as folows

a:\<null>b:\<null>c:\<null><null>

My Idea was to use strtok to tokenize it, since I have had luck tokenizeing other delimited lists.

Problem is my program crashes at address 78025ff6 inside MSVCRT.DLL

Turns out this is the Microsoft C library, And address 78025ff6 is just below following strtok. I disasembled it.

So it apears strtok is my problem:

GetLogicalDriveStrings(256, buffer);
char *drive, status[50];
drive = strtok(buffer, '\0');
strcpy(status, drive);
while(drive != NULL){
drive = strtok(NULL, '\0');
strcat(status, drive);
}

GetLogicalDriveStrings fills the buffer with the null delimited list format described above.

Can someone help me, I tryed strtok with a space delimited list and no problem, so the problem seems to be the null character is crashing strtok.