The command line parameters will consist of a DNS command and
then a number of IP-URI string pairs.
The DNS command is always a single letter followed by a search string.
A string pairs is always IP address then URI which must be placed
in the DNS store.
The example below has the DNS command U, search string 74.1.2.3,
and two IP-URI pairs.
lab3_s1235567 U 74.1.2.3 74.125.19.1 www.google.com 74.1.2.3 www.abc.net

* The program must insert all string pairs into a classes which you create
and then executed the command and print the result (with an endl)
to standard out.
In the example above the command is asking to find the URI of the
IP address 74.1.2.3. The output should be www.abc.net.

* Commands include-
U ip_address : find the IP address ip_address in the link list and
print out the matching URI.
I uri_name : search the link list for the URI given and print out
the matching IP address.

* If the search does not find a match output the string "nil".

* Error checking is not an aim in this lab and so do not do any error
checking. For example assume that-
- all parameters can be treated as strings, don't check for
the correct formation of IP addresses or URIs.
- there will always be a string pair or URI and IP in the right order.
- the command will always be U or I with a search string following.
- there could be anywhere from zero to 20 string pairs
(hint: use argc to work it out).

* The C++ string class "string" must be used.
The C string routines such as strcmp must not be used.

* The solution may use only one while loop to get command line parameters
into classes. Do not use any loop construct such as for or do.
(This is make sure you use a class solution.)

* The bulk of the code must be held in a class you create named ip_uri_store.
Each class must hold one string pair (ip and uri string).
The class ip_uri_store must have a constructor which saves the
new ip and dns string.

* The program must create dynamic copies of the class and
use pointers in each class to links classes together.
The IP-URI information must be placed in this structure
and all searching must use this structure.
The tutors will check every program by eye to ensure this is
the solution method used.

okay i understand now, i have gave it a shot but i am kinda stuck
here is what i have done

struct str_pair
{

char ip [50];

char uri [50];

str_pair *next;

};

str_pair *str_ptr;// pointer to an order struct, 

str_pair *list_head;// points to nothing initially.



int main(int argc, char *argv[])

{

 if (argc == 1)

 { 
cout << "my name"<<endl;

  return(0);
    }

//--- initialize link list to empty.

list_head = NULL;// can test for NULL to see if anything is there.

//str_ptr = new str_pair;  
//--- Create data at run time on the heap.

for (int i=0; i<argc ; i++)
{
str_ptr = list_head; // save old head of list.
list_head = new str_pair; // create new item.
list_head->next= str_ptr; // get next item to point to previous head.
list_head->next =i;

return(0);

}
}

what i need to know is how to introduce my uri and ip address and how do i attach them to the pointer? or maybe just hints

Edited 3 Years Ago by mike_2000_17: Fixed formatting

The funny thing is your assignment is asking you for classes and use of std::strings...

And your code uses structs and char arrays...

This article has been dead for over six months. Start a new discussion instead.