Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Need some ideas on making a Bin/Dec/Hex converter. (http://www.go4expert.com/forums/ideas-bin-dec-hex-converter-t1487/)

Mythion 29Sep2006 11:38

Need some ideas on making a Bin/Dec/Hex converter.
 
Hi, i am new in Go4Expert and i need some ideas on making a Bin/Dec/Hex converter(in C++)...
the main problems are:
1. when accessing an intger it's not possible to go over every digit it has like in arrays,
you can have a char array:
char arr[10]="Hello";
and the array is really "H", "e", "l", "l", "o"...
2. when you declare a intger array:
int arr[10];
you can't input a number such as "10011011" and the int array will be "1", "0", "0", "1", "..." and so on, to do so you can do a For loop, but then you have to input each number separately and this becomes a huge probelm with binary numbers such as "100101100011110111" and longer...

there are more problems but if one of these two are not solved there is no point going forward...

thanks in advance.

shabbir 29Sep2006 16:08

Re: Need some ideas on making a Bin/Dec/Hex converter.
 
Welcome to G4EF.

Regarding your problem you can do is get the binary number in the character array. Something like
Code:

char arr[10]="10011011"
and then typecast it to the array of integers or whatever you wish to do with like integers is possible.

Mythion 29Sep2006 21:19

Re: Need some ideas on making a Bin/Dec/Hex converter.
 
Good idea, i never thought of typecasting arrays...


All times are GMT +5.5. The time now is 20:52.