Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Help Parsing a Pipe Delimited String. (http://www.go4expert.com/forums/help-parsing-pipe-delimited-string-t20750/)

wgre0111 25Jan2010 07:19

Help Parsing a Pipe Delimited String.
 
Greetings,

Having issue storing the 3rd value in a pipe delimited string. dont care about the rest of the text... just want to choose the field i want and ignore rest. I hear strtok has some limitations where it would skip a field if it was blank... Dont want to have that possibility. Please Help!

Example: values = "1||3|NEED|4|5|"

I want to be able to parse out only the field after the 3rd pipe and store that field in a variable (OR after whatever pipe i choose)

kiddo 25Jan2010 14:36

Re: Help Parsing a Pipe Delimited String.
 
Can you explain more about the problem?
I don't get the point.

Maybe another example..

wgre0111 25Jan2010 18:02

Re: Help Parsing a Pipe Delimited String.
 
Lets see..

I have a variable that has the following information "1||3|4|NEED|5|hrrm|ok"

I need code to be able to choose WHICH ever field i want. like i want to be able able to say I want field 5 and have it return only the word NEED into output or into another variable.

strtok has its limitations because it will get tripped up over the blank field "||"

I know how to do this other ways but they require me to loop thru and use a counter to stop on the occurrence.

Just trying to avoid that with some type of scanf or anything that wont get tripped up over blank fields.

xpi0t0s 26Jan2010 05:15

Re: Help Parsing a Pipe Delimited String.
 
Quote:

Originally Posted by wgre0111 (Post 63372)
I know how to do this other ways but they require me to loop thru and use a counter to stop on the occurrence.

What's wrong with that? (It's what I'd do.)


All times are GMT +5.5. The time now is 07:57.