I'm printing a bunch of ascii chars to the console as a representation of binary numbers however whenever it prints out the number 7 to the console then windows makes a beeping noise. Looking online I can see some people talking about ascii 7 making a noise but I cant seem to find where to disable it in the code.
for (size_t i = 0; i < 1160; i++)
{
std::cout << "\n" << (char)decimalarray[i];
}
this occurs when the value in the UIN8 array is 7 and I try printing the value as a char.
printing (int)decimalarray[1157]
outputs the number 7
printing (char)decimalarray[1157]
outputs nothing but makes beeping noise
edit: it would probably be ideal if there was a way to only write printable characters. not easy to hardcode in the values as the program uses every ascii character there is in normal execution.
Can anyone help? thanks
Code 7 is bell. It is meant to do that.
To disable it, you have 2 choices.
To do the conditional: use isprint
e.g.
#include <ctype.h>
#include <iostream>
int main(){
int c =7;
if (isprint(c))
std::cout <<'\n' << static_cast<char>(c);
}