So I'm trying to remove 2 brackets from lines I'm reading from a file.
For some reason when I run my program the characters in between the delimeters is removed.

for example
greetings pe()ple
would end up as
greetings pe

I'm using a char array of delimiters.
char delimiters[] = " ( )";

Why does strtok delete the characters between the parenthesis?

Is this PHP? The function should be seperating the string into tokens based on the delimiter. In your example 'greeting pe' would become the first token of the tokenised string. The example from the PHP man page may help.

<?php
$string = "This is\tan example\nstring";
/* Use tab and newline as tokenizing characters as well  */
$tok = strtok($string, " \n\t");

while ($tok !== false) {
    echo "Word=$tok<br />";
    $tok = strtok(" \n\t");
}
?>

As you can see, $tok is used repeatedly to move through the string. SO if you did a loop like the one above further calls to strtok should move through your string.

Misunderstanding of how strtok works.
Have to seperate token into different fields.

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.