Tuesday, February 24, 2015

How to Uppercase a character array in One line code

#include<iostream>
#include<algorithm>
#include<conio.h>

using namespace std;

void main( )
{
    char myarray[30]={0};

   sprintf(myarray , "%s","this is my lower case string??");
   cout<<"\nBefore conversion : "<< myarray;
   transform(myarray ,myarray + std::strlen(myarray ), myarray , static_cast<int(*)(int)>(toupper));
  cout<<"\nAfter conversion : "<< myarray;

_getch( );

}


OutPut :

Before conversion : this is my lower case string??
After conversion :  THIS IS MY LOWER CASE STRING??


No comments:

Post a Comment