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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strtok question

Status
Not open for further replies.

kodr

Programmer
Dec 4, 2003
368
Can anyone point me in the right direction here?

I'm trying to parse a variable, where it contains 3 pieces of information.

A sample of the string looks like this:

"172.0.0.1 Miami 3"

The IP address, city name and last digit are all seperated by tabs (can't use spaces because of cities like "New York".)

I'm trying to use strtok to seperate out the individual pieces of data, but I'm not quite sure how.

Code:
sIP = ""
sMarket = ""
sTemp = ""
fgets 0 sTemp
strtok sIP sTemp "'t" 1
strtok sMarket sTemp "'t" 1
sPathTemp = sMarket

For brevity I left of the code where I open the file, that portion is working correctly, but I think my problem is the "'t", I thought that would tell it to seperate at a tab, but appearently it doesn't.

Any thoughts?
 
Okay, I hang my head in shame....

I refered to an older program I wrote and realized that you don't use the single quote('), you use the other one (`).........

Is it Friday yet?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top