Okay i thought i have solved the problem i had obviusly with ur help guys but i guess i was doing it wrong, here is what i am suppopse to do:

BACKGROUND This is the same as the DNS pointer problem except ypou must
structure your code into a class and use the C++ string class
to handle strings.
Your company is writing software for a new networking device and
you have the task of managing the DNS storage and retrieval.
DNS must translate between an Internet IP address such as
74.125.19.99 and the URI (in this case www.google.com).
The networking device is not available so the code has been
split into segments and each bit is being developed on a PC.
You have been allocated a code segment that must use classes
and pointers to form a link list record of these pairs of strings
( IP naddress and URI).
It must allow insertion, deletion, and querying.


SPECIFIC REQUIREMENTS : these are much the same as the DNS pointer lab
except for the class implementation.

* 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.
Here is what i did:

#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

//=== CLASS ip_uri_store ==================================================
class ip_uri_store
{
public:
string count;
int id;
ip_uri_store *next;
void ip_uri(string ip50,string uri50);
void uri_ip(string uri50,string ip50);

protected:
string ip50;
string uri50;

};
ip_uri_store *list_head;
ip_uri_store *work_ptr;

void ip_uri_store::ip_uri(string ip50,string uri50)
{
if(ip50=="74.125.19.1")
{
uri50="www.google.com";
cout<<uri50<<endl;
}
else if(ip50=="74.1.2.3")
{
uri50="www.abc.net";
cout<<uri50<<endl;
}
else
cout<<"nill"<<endl;
};

void ip_uri_store::uri_ip(string uri50,string ip50)
{
if(uri50=="www.google.com")
{
ip50="74.125.19.1";
cout<<ip50<<endl;
}
else if(uri50=="www.abc.net")
{
ip50="74.1.2.3";
cout<<ip50<<endl;
}
else
cout<<"nill"<<endl;
};




//====== MAIN ==========================================================

int main(int argc, char *argv[])
{//--- When no command line parameters MUST print id string in CSV format. 
   if (argc == 1)  // no parameters.
     { cout <<"name"<< endl ;
       return(0) ;
     }
list_head=NULL;
int i=0;
char ch;
string uri50;
string ip50;
while(i<argc)
{

work_ptr=list_head;
list_head=new ip_uri_store;
list_head->next=work_ptr;
list_head->count=argv[i];
list_head->id=i;
i++;
}

for(int k=1;k<2;k++)
{
 for(int j=0;argv[k][j] !='\0';j++)
   {
     ch=argv[k][j];
}
}
//cout<<ch<<endl;

if(ch=='U')
{
 ip_uri_store urip;
 uri50=argv[2];
urip.uri_ip(uri50,ip50="");
}
else if(ch=='I')
{
 ip_uri_store ipuri;
 ip50=argv[2];
ipuri.ip_uri(ip50,uri50="");
}
else
cout<<"nill"<<endl;



 
   return(0) ;
}

and this is the result i got from the auto-tester

Category = Parameter Errors =======

------- No IP-URI pairs --------------------
INCORRECTLY missed no IP-URI pairs.
Stimuli was "./test U 1.1.1.1", expected "nil", got "nill".


------- No IP-URI pairs --------------------
INCORRECTLY missed no IP-URI pairs.
Stimuli was "./test I 1.1.1.1", expected "nil", got "nill".


======= Category = searching =======

------- One pair match -------------------------
INCORRECTLY missed URI match.
Stimuli was "./test U 1.1.1.1 1.1.1.1 www.z.com", expected "www.z.com", got "nill".


------- One pair no match -------------------------
INCORRECTLY missed URI match.
Stimuli was "./test U 1.1.1.1 1.1.2.1 www.z.com", expected "nil", got "nill".


------- Two pairs with match -------------------------
INCORRECTLY missed URI match.
Stimuli was "./test U 1.1.1.1 2.2.2.2 a.b.c 1.1.1.1 www.z.com", expected "www.z.com", got "nill".


------- Two pairs no match -------------------------
INCORRECTLY missed URI match.
Stimuli was "./test U 2.1.1.1 2.2.2.2 a.b.c 1.1.1.1 www.z.com", expected "nil", got "nill".


------- Four pairs with match -------------------------
INCORRECTLY missed URI match.
Stimuli was "./test U 3.3.3.3 4.4.4.4 four 3.3.3.3 three 2.2.2.2 two 1.1.1.1 one", expected "three", got "nill".


------- Four pairs no match -------------------------
INCORRECTLY missed URI match.
Stimuli was "./test U 3.3.3.3 4.4.4.4 four 0.3.3.3 three 2.2.2.2 two 1.1.1.1 one", expected "nil", got "nill".


------- 20 pairs with match -------------------------
INCORRECTLY missed URI match.
Stimuli was "./test U 12 1 x1 2 x2 3 x3 4 x4 5 x5 6 x6 7 x7 8 x8 9 x9 10 x10 11 x11 12 x12 13 x13 14 x14 15 x15 16 x16 17 x17 18 x18 19 x19 20 x20", expected "x12", got "nill".


------- 20 pairs no match -------------------------
INCORRECTLY missed URI match.
Stimuli was "./test U 21 1 x1 2 x2 3 x3 4 x4 5 x5 6 x6 7 x7 8 x8 9 x9 10 x10 11 x11 12 x12 13 x13 14 x14 15 x15 16 x16 17 x17 18 x18 19 x19 20 x20", expected "nil", got "nill".

Apologies for the "dump of info" but i wanna make sure i didnt miss anything.

Recommended Answers

All 2 Replies

so no one can help to where is should be starting?!!!

so no one can help to where is should be starting?!!!

I think you're going to have to format your code and document it better and explain exactly what this is supposed to do and what it actually is doing so that we don't have to search through the assignment spec for what is supposed to be going on, what each variable represents, what each function does, etc. Document the code itself. The "nil" versus" "nill" looks like a simple typo. It's not clear (to me at least) what this program is supposed to do and what the strategy behind your code is. Why a linked list? Seems like you're parsing strings character by character, but I don't know why. Lines 84 - 90 in particular don't make any sense to me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.