Question: #include #include using namespace std; void text 2 bin _ IPv 6 ( const char * a , unsigned char * v ) { /
#include
#include
using namespace std;
void textbinIPvconst char a unsigned char v
a is the text format representation of the IPv address.
v is the binary IPv address to be produced by the conversion function.
v is the leftmost byte of the bit IPv address,
bit of v is the leftmost st bit of the IPv address.
for int k ; k ; k
vk;
Your codes. You may define additional supporting function where
appropriate.
This exercise is intended to train your organization skills.
Length of this function is longer than the previous tutorials.
Expected number of statements is about to
functions given to students
char toHexunsigned d
if d
return d a;
return d ;
void printIPvaddresshexconst unsigned char v
cout "IPv address hex;
for int i ; i ; i
cout toHexvi toHexvi;
if i && i
cout :;
cout endl;
void printIPvaddressbinconst unsigned char v
cout "IPv address bin;
for int i ; i ; i
cout bitsetvi;
if i && i
cout ;
cout endl;
void testconst char a
cout
;
cout "IPv address text a endl;
unsigned char v; bytes memory to store the bit IPv address
textbinIPva v;
printIPvaddresshexv;
printIPvaddressbinv;
int main
Test data : IPv addresses in text format
char a::;
char a::;
char a:abc:::ff:::;
char a:db:a:::;
char a:db::;
char a::::::;
testa;
testa;
testa;
testa;
testa;
testa;
systempause;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
