0

Why am I getting garbage output for about 30 iterations with this simple for loop?

Garbage is mostly at the start, but there is also some at the end. Here is my code. Any help is appreciated. #include<iostream> using namespace std; //for loop to display ASCII characters. int main() { for (int i = 0; i < 128; i++) { char ASCII = i; cout << ASCII << " "; if (i % 16 == 0) { //enters newline every 16 iterations cout << endl; } } return 0;

24th Jul 2017, 4:53 AM
James Jacobsen
James Jacobsen - avatar
3 Respuestas
+ 5
They're not garbage, they're just special characters. You can look at this: http://www.ascii-code.com/, look at the Symbol column to see which character corresponds to the char code.
24th Jul 2017, 5:05 AM
Bàng Tứ Cường
Bàng Tứ Cường - avatar
+ 2
You're welcome!
24th Jul 2017, 7:15 AM
Bàng Tứ Cường
Bàng Tứ Cường - avatar
0
Awesome, thanks a lot!
24th Jul 2017, 5:18 AM
James Jacobsen
James Jacobsen - avatar