Sinisterly
[NEED HELP] Text to binary code converter [Simple] - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Coding (https://sinister.ly/Forum-Coding--71)
+--- Thread: [NEED HELP] Text to binary code converter [Simple] (/Thread-NEED-HELP-Text-to-binary-code-converter-Simple)



[NEED HELP] Text to binary code converter [Simple] - Nazism - 03-22-2013

Code:
#include <string> #include <bitset> #include <iostream> #include <cstdlib> #include <string> #include <Windows.h> using namespace std; int main() { string convert; cout << "What to convert?: "; cin >> convert; string myString = convert; for (std::size_t i = 0; i < myString.size(); ++i) { cout << bitset<8>(myString.c_str()[i]) << endl; } Sleep(10000); }
And i may have included non-required stuff because i was working on an system that auto copy pastes the binary code to clipboard but i could not get it working (would appreciate if someone would help me with that)


RE: Text to binary code converter [Simple] - Nazism - 03-23-2013

Hey im trying to save the binary code result to a text file and it only prints the words first letter as binary code
Code:
#include <string> #include <bitset> #include <iostream> #include <fstream> #include <cstdlib> #include <string> #include <Windows.h> using namespace std; int main() { string convert; cout << "What to convert?: "; cin >> convert; string myString = convert; for (std::size_t i = 0; i < myString.size(); ++i) { ofstream myfile; myfile.open ("test.txt"); myfile << bitset<8>(myString.c_str()[i]); myfile.close(); return(1); } }



RE: Text to binary code converter [Simple] - Sunlight - 03-23-2013

(03-23-2013, 03:04 PM)Atex Wrote: Hey im trying to save the binary code result to a text file and it only prints the words first letter as binary code
Code:
#include <string> #include <bitset> #include <iostream> #include <fstream> #include <cstdlib> #include <string> #include <Windows.h> using namespace std; int main() { string convert; cout << "What to convert?: "; cin >> convert; string myString = convert; for (std::size_t i = 0; i < myString.size(); ++i) { ofstream myfile; myfile.open ("test.txt"); myfile << bitset<8>(myString.c_str()[i]); myfile.close(); return(1); } }

Use a openfiledialog to open the file, and a savefiledialog to edit/add to the textfile.


RE: [NEED HELP] Text to binary code converter [Simple] - Stickleā„¢ - 03-23-2013

I'm going to PM you about it, hopefully you can get this done.. binary is pretty fun to mess around with too.