Solved

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

Posted on 2007-11-30
6
173 Views
Last Modified: 2010-04-01
#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
Comment
Question by:Troudeloup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 

Author Comment

by:Troudeloup
ID: 20386570
or rather


bool is_upper ( string[n] )
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20386578
It is isupper() instead:

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


you have to include "stdlib.h" in your source file
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20386579
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Troudeloup
ID: 20386581
#include <"stdlib.h">

?
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 20386585
no, just <stdlib.h>  or "stdlib.h"

it is require by the isupper() function to work properly
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question