I need help parsing a const char * string. I am using strtok to parse it, however, after one successful return of strtok, I only get memory addresses, and the program crashes. So I figured I would copy the pointer string into an array, and strtok that... However when I strcpy it over, the array only reads memory addresses. Let me give you some code:

LPSTR lpTask;
char  buffer[256];
MessageBox(NULL, lpTask, "DEBUG", 0x00000000L); // Here lpTask points to the data i want
strcpy(buffer, lpTask);
MessageBox(NULL, buffer, "DEBUG", 0x00000000L); // Only reads memory addresses.

I believe I have elaborated enough, and sorry to those of you that facepalm when they see this, heh.

Thanks in advance

You can't use strtok() on a const char* because strtok() will change the contents of the string. Copy the const char* into a buffer and use that for strtok()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.