tolower error

This is a discussion on tolower error within the C++ Programming forums, part of the General Programming Boards category; Arggh, you're running in circles. ALL you have to do is remove the () from std::tolower(). Instead, you also removed ...

  1. #31
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,236
    Arggh, you're running in circles.

    ALL you have to do is remove the () from std::tolower(). Instead, you also removed the std:: in the front, which broke it again.

    Use "std::tolower"

  2. #32
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    *cough*
    Code:
    using namespace std;
    Not that that's a good idea, but because it's there, the std:: is not required.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #33
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    >> Not that that's a good idea, but because it's there, the std:: is not required.

    No, it is required because the compiler is confused about which version of tolower to use. This was explained much earlier in the thread.

  4. #34
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Now I'm confused. I looked, but I don't see what you mean . . . the compiler shouldn't be confused about which version of tolower() to use, because there's only one version, as long as only one of <ctype.h> and <cctype> is included.

    As far as I know, one should use std::tolower, unless there's a using namespace std or equivalent, in which case it's okay to leave off the std::. Can you elaborate?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #35
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    The best I can find:

    changing letter case

  6. #36
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Thanks for the link, it explains things very nicely. But it seems that <locale> defines tolower() (not <iostream>); but <iostream> could include <locale>, which might be why a lack of std:: works on some compilers and not others:
    1. tolower is (also) a template function prototyped in <locale>:

    template <class charT> charT tolower(charT c, const locale& loc);

    2. Any standard C++ header is allowed to include any other standard C++
    header as an implementation detail (reference 17.4.4.1/1).
    From http://www.thescripts.com/forum/thread62974.html

    So . . . to the OP: add std::.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  7. #37
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Quote Originally Posted by dwks View Post
    So . . . to the OP: add std::.
    Actually that won't work. What will work is ::tolower.

  8. #38
    Registered User
    Join Date
    Jan 2007
    Posts
    188
    Yeah it works!

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

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