The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
name to binary
Posted by: lol | November 19, 2010 @ 2:24am
C++ Code
[
Download
]
#include <iostream> #include <cstring> using namespace std; char *entry, letter, choice[2]; int ascii, len, binary[8], total; void bname(); int main() { bname(); cout << endl; system("pause"); } void bname() { entry = new char[501]; cout << "Enter Name :"; cin.getline(entry, 500); len = strlen(entry); for(int i = 0; i < len; i++) { total = 0; letter = entry[i]; ascii = letter; while(ascii > 0) { if((ascii%2)==0) { binary[total] = 0; ascii = ascii/2; total++; } else { binary[total] = 1; ascii = ascii/2; total++; } } total--; while(total >= 0) { cout << binary[total]; total--; } } delete[] entry; }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.47 / 8
36 Votes
http://codebin.yi.org/966
page generated in 0.00 seconds