Binary number from string to int array help
The following code is supposed to read in input from the keyboard, encode it to a string, and then take each digit from the string and put it into an integer array for the purposes of adding two binary numbers together.
See below for the test input and result.
Can anyone explain why this is so and how to fix it? I want to make sure I'm getting the right numbers in the right places before I move forward, as it will make the rest of the work that much easier.
Thanks!
INPUT: 11010010
OUTPUT: 0034FB90
Code:
#include <iostream>#include <string>
using namespace std;
int main()
{
int b1[8], b2[8], b3[9];
string s1, s2;
cout << "Please enter the first binary number to add: ";
cin >> s1;
cout << endl << endl;
for(int i=0; i<8; i++)
b1[i]=s1[i];
cout << b1;
system("pause");
return 0;
}