Click here to Skip to main content
15,887,848 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi! I have a .dat file like that:

C++
id product price
1 nokia 200
2 samsung 150
3 iphone 300
...
n .....  ..


How to find product and price when I select id by c++

Please give me a tip! thanks!
Posted

Read each line of text and use one of the tokenizer functions, such as strtok[^], to split each string.
 
Share this answer
 
XML
ref this
<a href="http://www.cplusplus.com/reference/cstring/strtok/">http://www.cplusplus.com/reference/cstring/strtok/</a>[<a href="http://www.cplusplus.com/reference/cstring/strtok/" target="_blank" title="New Window">^</a>]
 
Share this answer
 
Read the each line and put it in a map:

the key is id column, the value is the pair<string,int>.

then, according the id to query the value.
 
Share this answer
 
v2
Begin here...[^] :)
 
Share this answer
 
can you tell me detail or example, thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900