Solved

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

Posted on 2007-11-30
6
169 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

864 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now