Bachelors_Thesis_Code/fagprojekt_code/ascii_to_bits.cpp

58 lines
1.3 KiB
C++
Raw Normal View History

2021-11-14 14:35:05 +01:00
#include <stdlib.h>
/* #include <chrono> */
#include <iostream>
/* #include <stdio.h> */
/* #include <cmath> */
/* #include <string.h> */
/* #include <stdint.h> */
#include <bitset>
#include <fstream>
using namespace std;
int main() {
string s = "test";
const char * c = s.c_str();
for (size_t i = 0; i < s.size(); i++) {
cout << std::bitset<__CHAR_BIT__>( c[i] ) << " ";
}
cout << endl;
std::ifstream ifs("genji_monogatari_english.txt");
string genji( (std::istreambuf_iterator<char>(ifs) ),
(std::istreambuf_iterator<char>() ) );
const char * c2 = genji.c_str();
for (size_t i = 0; i < 1000; i++) {
/* cout << std::bitset<__CHAR_BIT__>( c2[i] ) << " "; */
cout << c2[i];
}
cout << endl;
/* cout << genji.size() << endl; */
/* unsigned char bitgenji[genji.size()]; */
/* for (size_t i = 0; i < genji.size(); ++i) */
/* { */
/* bitgenji[i] = static_cast<unsigned char>( bitset<8>(genji[i]).to_ulong() ); */
/* } */
/* for (size_t i = 0; i < 4; ++i) */
/* { */
/* cout << (bitset<8>) bitgenji[i] << endl; */
/* cout << (unsigned int) bitgenji[i] << endl; */
/* } */
/* for (size_t i = 0; i < 100; ++i) */
/* { */
/* cout << bitgenji[i]; */
/* } */
/* cout << endl; */
return EXIT_SUCCESS;
}