C++stringタイプ変換バイナリ


#include
using namespace std;

int main()
{
	string s = "abc";
	int x = 0;
	int a[0xFFFF];
	for (int i1 = 0; i1 < s.size(); i1++)
	{
		x = s[i1] - '0';
		int n, i, j = 0;
		i = x;
		while (i)
		{
			a[j] = i % 2;
			i /= 2;
			j++;
		}
		for (i = j - 1; i >= 0; i--)
			cout << a[i] ;
	}
}


実行結果は11000110010110011