Writing a C++ Program to Search an Index File From the Linux Command Line -


I have written a program that reads in the data file and creates an index file sorted by the data in the original file. However, I want to write "M" again another program that allows that user to search for this index file from the Linux command line. For example, they should be able to type

  search 12382 Prog5.idx  

There is information for the command line and for that record. I do not know how to complete it.

I wrote that index file (function) to create code:

  #include > KEY>> Name> Code> Code & gt;> Cost) {R record (name, code, cost); MyMap.insert (pair & lt; int, record & gt; (key, r)); } And {cout & lt; & Lt; "Error"; }} // What's stored in the map for print (std :: map & lt; int, record & gt; :: iterator x = myMap.begin (); x! = MyMap.end (); ++ x) {Cout & lt; & Lt; Setup (10) & lt; & Lt; X- & gt; First & lt; & Lt; ":" & Lt; & Lt; X- & gt; Second & lt; & Lt; Endl; }}  

and get the following output when running the above code:

  8: empty 0 $ 0.00 12165: item 16 30 $ 7.69 12345: item 086 45 $ 14.20 12382: Item 09 62 $ 41.37 12434: Item 044 21 $ 17.30 16541: Item 12 21 $ 9.99 21212: ITEMSON 19 $ 8.35 34186: Item 25 18 $ 17.75 41742: Item 14 55 $ 12.36  

Here I have done yet another program:

  #include & lt; Prog3.idx & gt; # Include & lt; Iostream & gt; # Include & lt; Fstream & gt; using namespace std; Int main (int argc, char ** argv) {if (argc & lt; 3) {std :: cerr & lt; & Lt; "Very few logic \ n"; Std :: exit (EXIT_FAILURE); } Int key = atoi (argv [1]); Const char * filename = argv [2]; Instream input; Input.open ("prog5.idx"); }  

But I'm not sure where to go from there can someone help me?

Use the map or multimap and search in STL. Create datatype in the remaining data with the index as the key. The program will read the entire file first and then find the searched index.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -