Thread: string to upper

  1. #1
    Registered User
    Join Date
    Nov 2012

    string to upper

    I must be staring at this for too long because Ive been able to do this simple loop in the past...not today. Im just trying to take a string including spaces or characters and convert it to uppercase letters. Where am I going wrong please?

         cout <<"\nPlease enter your full name: ";
         cout << endl;
         for (int x = 0; x < ch.length(); x++) 
         {            //takes each character and converts it to uppercase letters
         cout << (char)(toupper(;

  2. #2
    Registered User
    Join Date
    Oct 2012
    For a string, use the transform function to uppercase all letters, including those separated by spaces:

    using namespace std;
    void main()
    string ch;
    cout<<"\nPlease enter your full name: ";
    transform(ch.begin(), ch.end(),ch.begin(), ::toupper) //replacement function

  3. #3
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Nice, France
    @confused i hope you see what is the problem with the code of hss

  4. #4
    Join Date
    Oct 2007
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trying to upper case a string
    By pliang in forum C++ Programming
    Replies: 2
    Last Post: 07-17-2005, 08:57 AM
  2. Coverting a string into upper or lowercase
    By TheShaggmeister in forum C++ Programming
    Replies: 13
    Last Post: 07-13-2003, 02:21 AM
  3. Convert a string to upper case?
    By jpp1cd in forum C Programming
    Replies: 2
    Last Post: 12-12-2002, 06:49 PM
  4. string upper case
    By Shadow12345 in forum C++ Programming
    Replies: 1
    Last Post: 05-06-2002, 08:23 PM
  5. convert a string to upper case
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 03-14-2002, 07:36 PM