Solved

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

Posted on 2007-11-30
6
168 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
Comment Utility
or rather


bool is_upper ( string[n] )
0
 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:Troudeloup
Comment Utility
#include <"stdlib.h">

?
0
 
LVL 55

Accepted Solution

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

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

Author Comment

by:Troudeloup
Comment Utility
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

762 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

11 Experts available now in Live!

Get 1:1 Help Now