123456789101112131415161718192021222324
int bin_to_ascii(){ string wordtwo; char ch; cout<<"Type in binary that you would like converted to ascii!"<< endl; getline(cin, wordtwo); for (int x = 0; x < wordtwo.length() / 8; ++x) { int conv = 0; for(int y = 0; y < 8; y++) { char ch = wordtwo.at(x*8+y); if(ch == '1') conv += 1 < (7-y); else if(ch != '0'); } { cout<<" " << ch <<"Input valid binary!"<<endl; } cout<< static_cast<char>(conv); } cout<< " " << endl; return 0; }