我有以下cout<< 1100001011000100110001101100100
我希望一次从中选择16位,并按以下方式将其保存到数组中:
这是我的代码:
#include <iostream>
using namespace std;
int main()
{
char character;
int i;
int m[8];
cout<<"Please enter a character string: ";
cin>>character;
cout<<"You've entered "<<character<<endl;
//i entered abcd it gives me 01100001011000100110001101100100 in cout. how should i save this
as a continuous array?
for(i=0;i<8;i++)
{
m[i]=character%2;
character = character/2;
}
int top, bottom;
for(bottom=0,top =7; bottom<8; bottom++,top--)
{
m[bottom]=m[top];
cout<<m[top];
}
return 0;
}