Solved

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

Posted on 2007-11-30
6
172 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
 

Author Comment

by:Troudeloup
ID: 20386586
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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.

733 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