Your while test isn't doing you any good down in the sequence. Let's say the second strtok doesn't find a token. It returns NULL. You aren't testing for that, you're dereferencing a NULL pointer when you attemp the strcpy. The problem isn't with strtok. As usual, it's with the coder.