Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

JASdeep11

  • 3 years ago

how would you change all the character of a string to uppercase in c++

  • This Question is Closed
  1. dk-info
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Create a lookup table with 26 positions indexed by the ASCII value of the character to be changed. The value in the lookup table at a particular location is the upper case ASCII value.

  2. rsmith6559
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    int i = 0; while( string[i] ) { if( string[i] >= 'a' ) && ( string[i] <= 'z' ) string[i] &= 0xDF; // or string[i] = tolower( string[i] ); // you'll need: #include <cctype> }

  3. pointme
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    //This program convert the string to upper case #include<iostream> #include<cstring> #include <cctype> using namespace std; int main() { string str ="my real name is secret munyai from university of limpopo south africa"; int leng=str.length(); cout <<"your string :"; for (int i=0 ;i<=leng-1 ;i++) { cout<<str[i]; } cout<< "\n your string is now in upper cass :"<<endl; //convert to upper case for (int i=0 ;i<=leng-1 ;i++) { str[i]=toupper(str[i]); cout<<str[i]; } cout<<endl; return 0; }

  4. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy