I have a problem is converting char* to char. This is my code...
CODE
int n;
char output[256];
char srcport1[256],srcport2[256],dstport1[256],dstport2[256];
stack<char*> port1;
cout<<"Protocol Number:";
cin>>n;
sprintf(output,"%x",n);
cout<<output<<endl;
cout<<strlen(output)<<endl;
if(strlen(output)< 4 )
{
port1.push(output);
for(int i=0; i< (4 - strlen(output)); i++)
{
port1.push("0");
}
}
for(int i =0; i < 2; i++)
{
srcport1[i] = port1.top();
port1.pop();
}
for(int i =0; i < 2; i++)
{
srcport2[i] = port1.top();
port1.pop();
}
It says " C:\Documents and Settings\Mahendran Armugam\Desktop\COMPUTER NETWORKS ASSIGMENT\netdump.cpp invalid conversion from `char*' to `char' " and when i tried this..
CODE
for(int i =0; i < 2; i++)
{
srcport2[i] = (char)port1.top(); //
port1.pop();
}
cout<<srcport2<<endl; //this displays some garbage value (¶¶>?@abcÉ☺=)
Can somebody help me out please...
Thanks...