• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

how do I find out if it's upper case letter?

#include <iostream>

using namespace std;

int main()
{
      string string1 = "Hh";
      
      cout << string1 << endl;
      
      if ( string1[0] == "H" )
      {
            cout << "is upper case " << endl;
      
      }
      return 0;
}
0
Troudeloup
Asked:
Troudeloup
  • 3
  • 3
1 Solution
 
TroudeloupAuthor Commented:
or rather


bool is_upper ( string[n] )
0
 
Jaime OlivaresSoftware ArchitectCommented:
It is isupper() instead:

 if ( isupper( string1[0] ) )
      {
            cout << "is upper case " << endl;
     
      }


you have to include "stdlib.h" in your source file
0
 
Jaime OlivaresSoftware ArchitectCommented:
Complete example:
#include <iostream>
#include <stdlib.h>
 
using namespace std;
 
int main()
{
      string string1 = "Hh";
      
      cout << string1 << endl;
      
      if ( isupper(string1[0]) )
      {
            cout << "is upper case " << endl;
      }
      return 0;
}

Open in new window

0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
TroudeloupAuthor Commented:
#include <"stdlib.h">

?
0
 
Jaime OlivaresSoftware ArchitectCommented:
no, just <stdlib.h>  or "stdlib.h"

it is require by the isupper() function to work properly
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now