Need some ideas on making a Bin/Dec/Hex converter.

Mythion's Avatar, Join Date: Sep 2006
Newbie Member
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's Avatar, Join Date: Jul 2004
Go4Expert Founder
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's Avatar, Join Date: Sep 2006
Newbie Member
Good idea, i never thought of typecasting arrays...