Thread: Help Converting a String to uppercase using TOUPPER()

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    34

    Help Converting a String to uppercase using TOUPPER()

    Hi all, im new on this board and just thought id give it a try and see if any of you lot could help me out with my problem.

    im trying to convert a string IE "degrees" to uppercase letters using the toupper statement, this works with single chars but not with a string.

    Does anyone know what im doing wrong or why it wont work, or another method ive overlooked.

    Cheers

    e.g. temp = toupper(temp);

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    You use a for loop to apply toupper to each char in turn
    string[i] = toupper( string[i] );
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    34
    Thnx, im still having trouble with this damn prog, i know this is a little cheecky, but ill put my source file up and if anyone can be bothered to have a look and tell me where im going wrong id be really grateful

    thnx

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    > sign == "CELSIUS"
    This is not how you compare strings

    Do this
    if ( strcmp( sign, "CELSIUS" ) == 0 ) {
    }

    strcmp is in string.h
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    34
    thanks alot m8, i owe you one

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  2. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  3. Converting a string of words into correct cases
    By BigFish21 in forum C++ Programming
    Replies: 2
    Last Post: 05-26-2008, 12:53 AM
  4. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 03:40 AM
  5. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM