Tolower

This is a discussion on Tolower within the C++ Programming forums, part of the General Programming Boards category; What I am trying to do is get the first letter from a person's name using the substr function, and ...

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    36

    Tolower

    What I am trying to do is get the first letter from a person's name using the substr function, and then change the letter to lowercase. This is my code to do that:

    Code:
    firstLetter = final_last_name.substr(0, 1);
    firstLetter = static_cast<string>(tolower(firstLetter));


    Every time I try to compile the program, it gives me this error message:
    error C2664: 'tolower' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'int'


    I am using the header file cctype for the function tolower, and I have tried changing that "char" inside the static cast to "string" since I am manipulating strings in this program, but nothing seems to budge.

    Any ideas would be appreciated. Thanks.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >Any ideas would be appreciated.
    Code:
    firstLetter = tolower ( final_last_name[0] );
    Assuming firstLetter is suitably declared.
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    36
    Ah, I thought I would have to keep static_casting to change it to a lower case letter. I guess I keep forgetting that static casting is only for changing a data type.

    I appreciate your help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. tolower and locale
    By MK27 in forum C Programming
    Replies: 16
    Last Post: 02-03-2009, 09:05 PM
  2. tolower error
    By Livijn in forum C++ Programming
    Replies: 37
    Last Post: 06-01-2007, 12:37 AM
  3. tolower function problem
    By Jack-Bauer in forum C++ Programming
    Replies: 6
    Last Post: 05-19-2006, 12:17 AM
  4. how do you use tolower()
    By panfilero in forum C Programming
    Replies: 3
    Last Post: 11-03-2005, 01:18 PM
  5. Newbie - tolower()
    By 98dodgeneondohc in forum C Programming
    Replies: 7
    Last Post: 04-14-2005, 08:55 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21