to lower or to upper that is the question!

This is a discussion on to lower or to upper that is the question! within the C++ Programming forums, part of the General Programming Boards category; No, the reason is that the upper case part is only called if the first character of the string is ...

  1. #16
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    No, the reason is that the upper case part is only called if the first character of the string is lowercase.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  2. #17
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >No, the reason is that the upper case part is only called if the first character of the string is lowercase.
    I'm referring to this in the original post:
    s22 "BaLLooN" String Length: 7
    Lower Case:
    blln
    Upper Case:

    t22 "BaLLooN" String Length: 7
    Lower Case:
    blln
    Upper Case:

    u22 "BaLLooN" String Length: 7
    Lower Case:
    blln
    Upper Case:
    Notice the conspicuous absense of any Upper Case: output.

  3. #18
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    Right, that happens because when this runs:
    Code:
    cout << "Upper Case: "<< m_lower<< endl;
    m_lower points to the null terminator. Then, when this runs:
    Code:
    if(islower (*m_upper))
    it is false because *m_upper is 'B' which is not lowercase, so the for loop does not get run to convert to uppercase, as CornedBee mentioned.

  4. #19
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >it is false because *m_upper is 'B' which is not lowercase
    Ah yes, I see now.

  5. #20
    Registered User verbity's Avatar
    Join Date
    Nov 2006
    Posts
    101

    Re: More issues!!!

    I have another problem...

    I have an overloaded << operator that won't work with external ofstream csis(csis is just a text file)...the errror I"m getting is:

    c:\documents and settings\hp_administrator\my documents\visual studio 2005\projects\stringstuff\case.cpp(62) : error C2678: binary '<<' : no operator found which takes a left-hand operand of type 'std:fstream' (or there is no acceptable conversion)

    my simple little function looks like this:

    Code:
    ostream& operator<<(ostream& os, String& str)
    {
    	os << str.getBuf() << endl;
    	return os;
    }
    where the declaration is:

    friend ostream& operator<<(ostream&, const String& str);


    Anyone?? Anyone??? I have not the slightest clue.... I hope that's enough information too::

  6. #21
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Glad this board is back! Vector question
    By hpy_gilmore8 in forum C++ Programming
    Replies: 9
    Last Post: 02-23-2004, 11:13 AM
  2. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  3. upper case to lower case problem
    By Jasonymk in forum C++ Programming
    Replies: 3
    Last Post: 04-27-2003, 05:35 AM
  4. Lower to Upper
    By Krush in forum C Programming
    Replies: 13
    Last Post: 11-19-2002, 09:14 PM
  5. lower to upper
    By Unregistered in forum C Programming
    Replies: 12
    Last Post: 07-29-2002, 07:50 PM

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