我需要将我的比特流捕获到一个字符串中并继续连接该字符串。但是,我不确定该怎么做。有任何想法吗?
#include <bitset>
#include <iostream>
#include <string>
using namespace std;
int main ()
{
int i;
char data[30];
int int_arr[30];
printf("\nEnter the Data Bits to be transmitted : ");
scanf("%s",data);
// convert it into bitstream
for (i=0; i<strlen(data); i++)
{
int_arr[i] = int(data[i]);
}
for (i=0; i<strlen(data); i++)
{
cout << int_arr[i]<<endl;
cout << std::bitset<8>( int_arr[i] )<<endl; // Placeholder
}
return 0;
}
在标记为“//Placeholder”的行中,我真的不需要“计算”它,而是必须将比特流捕获到一个字符串中并继续连接它。