In: Computer Science
Change the ones with Bold text on the code accordingly.
The code within the if statement is not doing the correct process. When your code goes to the c2 function it should be passing argv[1] to it.
(side note: your program design of calling the function c1(), c2() c3() is a bit odd, but it can work)
if (argv[2] == _c2) { ret = c1(argv[2]); ret = ret >> 2;//divide by 2 to make it 8 bit } else if (argv[2] == _c1) { ret = c2(argv[1]); ret = ret >> 2;//divide by 2 to make it 8 bit // this should be done in the c2() funciton } else if (argv[1] == _c3) { ret = c3(argv[2]); ret = ret >> 2;//divide by 2 to make it 8 bit // this should be done in the c2() funciton } else if (argv[1] == _c4) { ret = c4(argv[2]); ret = ret >> 2;//divide by 2 to make it 8 bit // this should be done in the c2() funciton } else { cout << "'V' - Invalid operation selection" << endl; exit(0); }
Given :
To change the ones with Bold text on the code accordingly.
if (argv[2] == _c2)
{
ret = c1(argv[2]);
ret = ret >> 2;//divide by 2 to make it 8 bit
}
else if (argv[2] == _c1)
{
ret = c2(argv[1]);
ret = ret >> 2;//divide by 2 to make it 8 bit // this should be done in the c2() funciton
}
else if (argv[1] == _c3)
{
ret = c3(argv[2]);
ret = ret >> 2;//divide by 2 to make it 8 bit // this should be done in the c2() funciton
}
else if (argv[1] == _c4)
{
ret = c4(argv[2]);
ret = ret >> 2;//divide by 2 to make it 8 bit // this should be done in the c2() funciton
}
else {
cout << "'V' - Invalid operation selection" << endl;
exit(0);
}
Given to change the text given on bold.They are just comments on c/c++.Those comments do not effect the actual program.However , the modified comments with the code is given below:
if (argv[2] == _c2) { ret = c1(argv[2]); ret = ret >> 2; //divide by 2 to make it 8 bit } else if (argv[2] == _c1) { ret = c2(argv[1]); ret = ret >> 2;//divide by 2 to make it 8 bit // this should be done in the c1() function since else if(argv[2]== _c1) } else if (argv[1] == _c3) { ret = c3(argv[2]); ret = ret >> 2;//divide by 2 to make it 8 bit // this should be done in the c3() function since else if(argv[1]== _c3) } else if (argv[1] == _c4) { ret = c4(argv[2]); ret = ret >> 2;//divide by 2 to make it 8 bit // this should be done in the c1() function } else { cout << "'V' - Invalid operation selection" << endl; exit(0); }