c-program control, conversions
I am trying to get this program to convert any num or any letter to its respective equivalent. Thinking of using the "base 2, 10, 8, and 16" and have the program perform the conversion but don't know how. This is as far as i got before getting stuck. this do run but don't do what i want it to do.I guess i may be in deeper then i thought or just don't know what the heck i'm doing yet.
alittle help please would b greatful.
thanks
Glenn
#include <stdio.h>
#include <stdlib.h>
int main()
{
int conversion;
int dDecimal = 0, bBinary = 0, oOctal = 0, hHexadecimal = 0;
printf("\nEnter what you want converted.\t ");
printf("Enter KEYBOARD CTRL + Z to end.\n\n ");
while ( ( conversion = getchar() ) != EOF)
{
switch (conversion)
{
case 'd': case 'D':
dDecimal >= 10;
break;
case 'b': case 'B':
bBinary => 11111111;
break;
case 'o': case 'O':
oOctal => 7;
break;
case 'h': case 'H':
hHexadecimal => 9;
break;
case '\n': case ' ' :
break;
default:
printf("Your entry cannot be reconized.");
printf("Please re-enter what you want converted.\n");
}
}
printf("\nThe following is the converted\t");
printf("equivalent to your entry:\n ");
printf("\nDecimal equivalent is: %c\n", dDecimal);
printf("\nBinary equilalent is: %c\n", bBinary);
printf("\nOctal equivalent is: %c\n", oOctal);
printf("\nHexadecimal equivalent is: %c\n\n", hHexadecimal);
system("PAUSE");
return 0;
}:(