'Forbids comparison between pointer and integer

Hello,
I'm very new to C++ I'm taking it for school and I'm coming from a Python background (still a beginner in that as well), I need help with the following code posted below. I'm trying to get my code to do the following.

- Prompt users to enter their initials
- read those initials back to them (capitalized)
- run a loop that keeps asking for a valid alphabetical character

notes:
I'm trying to limit the amount of initials they can put in, so I'm only allowing 3 initials and leaving an extra for the null space.

Also, this code isn't fully completed, It keeps giving me error messages when I compile it.

Thank you everyone!



4 //The first section of this program is going to take initials and cap them.
5 //
6 //
7
8 #include <iostream>
9 #include <string>
10 using namespace std;
11
12 int main()
13 {
14 char initials[4];
15 cout << "Please enter your initials: " << endl;
16 cin >> initials;
17 cout << "You entered," << initials << endl;
18 while(initials < 'A' || initials > 'Z')
19 {
20 cout << "You've entered," << toupper(initials) << endl;
21 }else
22
23 {
24 cout << "Please enter alphabetical characters only." << endl;
25 }
26
27
28
29
30
31
32 return 0;
33 }
Line 14, you are declaring an array of characters.

Line 18, you are trying to compare this array to a character, which makes no sense. What are you trying to do here?
I'm trying to confirm the information the user enters is alphabetical. I don't want them entering other characters that could be mistaken for a person's initials. I want the loop to keep prompting for a character until it gets it, then after it does it will display their initials in uppercase.
Topic archived. No new replies allowed.