Having trouble adding 2 binary numbers in c++

This is a discussion on Having trouble adding 2 binary numbers in c++ within the C++ Programming forums, part of the General Programming Boards category; I'm having trouble adding 2 binary numbers in C++, instead of having the user input the binary numbers into the ...

Having trouble adding 2 binary numbers in c++

I'm having trouble adding 2 binary numbers in C++, instead of having the user input the binary numbers into the array (which I've gotten down) I shortened it to use two predetermined numbers 1010 + 0110, which should total to 10000, but the result I'm getting is 0012FEB0. Could anyone tell me where I'm going wrong with this?
Thanks in advance for any help.

I would make a new function with the following parameters at a minimum.

void b2_addition (int *c, int *a, int *b);

You will add binary numbers in the normal fashion, but store the answer in c. Use your knowledge of arrays to carry you through.

There is no problem returning an integer exactly, but you will have to correctly copy the answer you would get into an integer variable, by say, moving 1s into the correct place with bitwise operators. I view storing the answer in an array as consistent with how you want to use the function, though.