Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strtok with consecutive delimiters

Status
Not open for further replies.

hoohaahii

Programmer
Mar 6, 2011
8
GB
Hello,

Say I have the following string str = "1,2,3,,,4"

when I'm applying the strtok function

strtok(str,",") and printing the output it is returning the following

3 5 6 5

is there any way to make it return

3 5 6 0 0 5

it looks strtok is jumping through all the commas and returning the next token.

thanks a lot
A.Y.A
 
omg hehehe, sorry the output is

1 2 3 4

and I want it to be

1 2 3 0 0 4

sorry.
A.Y.A
 
>it looks strtok is jumping through all the commas and returning the next token.
Yes, that's strtok step specification: skip delimiters, scan token until the next delimiter or end of string. The strtok can't select empty tokens.

Make your own scanner by hand.
 
Thank you Olded, exactly what I wanted to do.

it worked perfectly thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top