Have a problem with a challenge in my C++ class.
The goal is to output all ASCII characters from 0-127 with 16 characters per line.
What we have had an issue with is certain chars such as 10 (n) are doing what they’re supposed to do rather than display “n”. My instructor does not know the solution to this either.
This is what I have:
int main ()
{
for (int i = 0; i <= 127; i++) {
cout << setw(4) << i << ": " << (char)i << " ";
if ((i + 1) % 16 == 0) {
cout << endl;
// Not sure why this doesn't seem to be displaying correctly? Possibly it's because of what some of the earlier ascii characters do/are
}
}
return 0;
}
We have found a couple possible solutions including Raw, which does not seem to work with variables.
haven’t managed to make fprint work for it either
Dylan Carney is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1