Can't stop endless loop...

Hello,

I have this problem and I can't stop it looping only 'A'...it won't print 'A' through 'Z'?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include<iostream>
#include<string>
using namespace std;



int main()
{
	cout << "here is a list" << endl;
	char letter = 'A';

	while (letter <= 'Z')
	{
		cout << letter << '\t' << static_cast<int>(letter) << endl;
	}

	return 0;

}
You are never changing letter
I don't understand?
letter's value never changes so the loop's condition is always true.
I am new to this...please help on how the syntax would be written?
Well I have no idea what your program is for. Try letter++.
Ok...I will try that...

So should the while loop look like this...

while (letter <= 'Z', letter ++)
No, it's a while loop! You need to go read the tutorial on control structures. Your questions suggest that you need a lot of help on this, and I truly mean no offense. (Otherwise I wouldn't have passed you a link.)
http://www.cplusplus.com/doc/tutorial/control/
Comma operator should really be avoided unless your use for it is specific. For clarity and style you should have the ++ in the while loop's body.
Topic archived. No new replies allowed.