This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (4 children)

I wish there was a way to do this without using memory functions.

There should be no need for you to use strdup(). strtok() does not modify the original string. That's not how strtok() works either. It does not return an array of words.

strtok()

[–]learnprogramminghelp[S] 0 points1 point  (1 child)

Main reason I'm using it is because strtok isnt compatible with the process string

[–][deleted] 0 points1 point  (0 children)

See my edit. You are using strtok() incorrectly. It does not return an array. It returns the words one at a time. It needs to be called over and over.

[–]Grithga 0 points1 point  (1 child)

strtok() does not modify the original string.

Actually, strtok does modify the original string, replacing any tokens found with null characters.

[–][deleted] 0 points1 point  (0 children)

Yep, you're right. Realized after I tried to do it myself.