Search
 
SCRIPT & CODE EXAMPLE
 

CPP

char to binary

#include <iostream>
#include<string>
#include<list>
using namespace std;
int main()
{
	while (true) {
		cout << endl << "Enter your char : " << endl;
		char c;
		int result[8] = {};
		cin >> c;
		int ascii_value = (int)c;
		cout << "Ascii = " << ascii_value << endl;
		try {
			for (int count = 0; count < 8; count++) {
				if (ascii_value % 2 == 0) {
					ascii_value = ascii_value / 2;
					//cout << "0";
					result[count] = 0;
				}
				else {
					//cout << "1";
					result[count] = 1;
					ascii_value = (ascii_value - 1) / 2;
				}
			}
		}
		catch (...)
		{
			cout << "PASS";
		}
		for (int count = 7; count > -1; count--) {
			cout << result[count];
		}
	}
} by ismail mazumder
Comment

PREVIOUS NEXT
Code Example
Cpp :: Calcular el número mayor y menor C++ 
Cpp :: C++ if...else 
Cpp :: fasdf 
Cpp :: c++ program to convert kelvin to celsius 
Cpp :: c++ caps lock key 
Cpp :: all in one c++ 
Cpp :: copy constructor in c++ questions 
Cpp :: leetcode 36 c++ 
Cpp :: c++ insert vector into vector 
Cpp :: Character convert c++ 
Cpp :: convert char to C 
Cpp :: # in c++ 
Cpp :: c + + to c converter 
Cpp :: time optimisation c++ 
Cpp :: Problems in your to-do list codechef solution in c++ 
Cpp :: c++ operators 
Cpp :: 2d stl array 
Cpp :: convert c++ code to exe 
Cpp :: polymorphism c++ virtual 
Cpp :: The elements are store at contiguous memory locations in C++ 
Cpp :: are maps sorted c++ 
Cpp :: template in cpp 
Cpp :: c++ cout int 
Cpp :: c++ map key exists 
Cpp :: size of set c++ 
Cpp :: x += c++ 
Cpp :: sinonimo de tratar 
C :: how to use gotoxy in c language 
C :: golang loop through array 
C :: same project on different monitor in intellij mac 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =