This must be a pretty simple thing to do, but unfamiliar with the language say you have a txt file that is set up like a table and has a number of tab separated columns, the first column being the key you match against so:
key col1 col2 col3
=== === === ===
00 10 20 30
01 40 50 60
02 70 80 90
03 00 05 10
04 15 20 25
Now the function would be called something like this
So the key column is column 0, col1 is column 1 and so on, so if were to call the above function like so
Then the value returned would be 70. so the pseudo code is quite easy
readTable(path_to_table,retrieve_column,key)
open table(path_to_table)
read each line until key is matched
retrieve the value from passed column number
So C gurus, how would this be done. Btw this is to prove a point to one of my work colleagues, I said this would be pretty easy for a clever C programmer to knock up in less than half a day, he doesn't agree.
It can't be that hard can it?
key col1 col2 col3
=== === === ===
00 10 20 30
01 40 50 60
02 70 80 90
03 00 05 10
04 15 20 25
Now the function would be called something like this
Code:
char * string = readTable(path_to_table,retrieve_column,key);
So the key column is column 0, col1 is column 1 and so on, so if were to call the above function like so
Code:
readTable("C:\table.tab",1,"02")
Then the value returned would be 70. so the pseudo code is quite easy
readTable(path_to_table,retrieve_column,key)
open table(path_to_table)
read each line until key is matched
retrieve the value from passed column number
So C gurus, how would this be done. Btw this is to prove a point to one of my work colleagues, I said this would be pretty easy for a clever C programmer to knock up in less than half a day, he doesn't agree.
It can't be that hard can it?