tags:

views:

23

answers:

2

I have a text file which read: config<001>25 23<220>12 .....

how can i parse so that i need only the values config,001(to be converted into integer after extracting using strtok or any ohter methods please suggest), and 25(to be converted into integer) seperately. i tries strtok its not working as the way i need. Please help me.

A: 

Use LINQ 2 SQL to import the file on the delimiters and then use something like AutoMapper to do the mapping of fields to say specific objects with specific types.

I did this exact thing in another project and it works great.

griegs
A: 

Based on the mention of strtok I'm guessing that you're using C or C++. If you're using C++, I'd probably handle this by creating a ctype facet that treats < and > as white space, which will make the parsing trivial (infile >> string >> number1 >> number2;).

If you're using C, you can use the scan-set conversion with scanf, something like: sscanf(line, "%[^<] %d> %d", string, &number1, &number2);

Jerry Coffin