Hello, I am currently working on to create text to Binary converter. There is no problem in the code. However I want to type the text(to convert it into binary) after the build of the code. I tried to find a way by using cin so that I could enter the text after the build, but it doesn't work. Is there a way to type the text after the build?
There is no problem in the code below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
#include <bitset>
usingnamespace std;
string TextToBinaryString(string words) {
string binaryString = "";
for (char& _char : words) {
binaryString +=bitset<8>(_char).to_string();
}
return binaryString;
}
int main()
{
string Text = "Hello world";
cout << "text: " << Text << "\n";
cout << "Convert text to binary: " << TextToBinaryString(Text) << "\n";
return 0;
}