change lowercase sentence to the uppercase

change lowercase sentence to the uppercase

Page 1 of 1

4 Replies - 1049 Views - Last Post: 01 June 2009 - 06:53 AM Rate Topic: -----

#1 shameela  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 01-June 09

change lowercase sentence to the uppercase

Post icon  Posted 01 June 2009 - 01:01 AM

change lowercase sentence to the uppercase

change New Road sentence to the NEW ROAD
Is This A Good Question/Topic? 0
  • +

Replies To: change lowercase sentence to the uppercase

#2 IngeniousHax  Icon User is offline

  • |>|20-514<|{3|2

Reputation: 78
  • View blog
  • Posts: 1,358
  • Joined: 28-March 09

Re: change lowercase sentence to the uppercase

Posted 01 June 2009 - 01:04 AM

Do you have any code to show us? If so please post it and let us know of any errors you are getting...Help us help you.

Also research the if(islower())...I'm sure your C++ book would have this in the index.
Or here-->http://cplusplus.com/reference/clibrary/cctype/islower/

This post has been edited by IngeniousHax: 01 June 2009 - 01:05 AM

Was This Post Helpful? 0
  • +
  • -

#3 apw5020  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 666
  • Joined: 26-March 09

Re: change lowercase sentence to the uppercase

Posted 01 June 2009 - 05:34 AM

#include <cctype> has the members toupper and tolower. They are used like this:
string someString = "all lower";
for(int i = 0; i < someString.size(); i++)
	  someString[i] = toupper(someString[i]); //Or tolower


to convert one character at a time, I believe.

This post has been edited by apw5020: 01 June 2009 - 05:35 AM

Was This Post Helpful? 0
  • +
  • -

#4 firebolt  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 92
  • View blog
  • Posts: 5,561
  • Joined: 20-February 09

Re: change lowercase sentence to the uppercase

Posted 01 June 2009 - 05:47 AM

Maybe something similar to this:
char toupper(char ch) {
    if (ch < 'a' || ch > 'z') {
        return ch;
    }
    return ch - ('a' - 'A');
}

char tolower(char ch) {
    if (ch < 'A' || ch > 'Z') {
        return ch;
    }
    return ch + ('a' - 'A');
}


Was This Post Helpful? 0
  • +
  • -

#5 AndyH1963  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 22
  • View blog
  • Posts: 201
  • Joined: 22-June 08

Re: change lowercase sentence to the uppercase

Posted 01 June 2009 - 06:53 AM

View Postshameela, on 1 Jun, 2009 - 07:01 AM, said:

change lowercase sentence to the uppercase

change New Road sentence to the NEW ROAD



If you are using the STL you could do:

#include <string>
#include <algorithm>

using namespace std;

int main(int argc, char* argv[])
{
	string s("New Road");
	transform(s.begin(), s.end(), s.begin(), toupper);

	return 0;
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1