Example #1
0
int main()
{
   cout << "According to islower:\n"
      << ( islower( 'p' ) ? "p is a" : "p is not a" )    
      << " lowercase letter\n"
      << ( islower( 'P' ) ? "P is a" : "P is not a" ) 
      << " lowercase letter\n"
      << ( islower( '5' ) ? "5 is a" : "5 is not a" ) 
      << " lowercase letter\n"
      << ( islower( '!' ) ? "! is a" : "! is not a" ) 
      << " lowercase letter\n";

   cout << "\nAccording to isupper:\n"
      << ( isupper( 'D' ) ? "D is an" : "D is not an" ) 
      << " uppercase letter\n"
      << ( isupper( 'd' ) ? "d is an" : "d is not an" ) 
      << " uppercase letter\n"
      << ( isupper( '8' ) ? "8 is an" : "8 is not an" ) 
      << " uppercase letter\n"
      << ( isupper('$') ? "$ is an" : "$ is not an" ) 
      << " uppercase letter\n";

   cout << "\nu converted to uppercase is " 
      << static_cast< char >( toupper( 'u' ) )
      << "\n7 converted to uppercase is " 
      << static_cast< char >( toupper( '7' ) ) 
      << "\n$ converted to uppercase is " 
      << static_cast< char >( toupper( '$' ) ) 
      << "\nL converted to lowercase is " 
      << static_cast< char >( tolower( 'L' ) ) << endl;
   return 0;
} // end main
Example #2
0
int main(int argc, const char *argv[])
{
	string str("hello world!");
	cout << "before: " << str << endl;

	string::iterator iter = str.begin();
	while (iter != str.end())
	{
		if (islower(*iter))
			*iter = toupper(*iter);
		++iter;
	}	
	cout << "after: " << str << endl;
	return 0;
}
Example #3
0
void printLatinWord( char *x )
{
	char *y = x;
	int size = 0;
	while( *y != '\0' )
	{
		size++;
		y++;
	}
	char arr[ size + 3 ];
	strcpy( arr, x );
	char copy = arr[ 0 ];
	if ( islower( copy ) == false )
	{
		copy = tolower( copy );
		arr[ size - 1 ] = toupper( arr[ size - 1 ] );
	}
	arr[ 0 ] = arr[ size - 1 ];
	arr[ size - 1 ] = copy;
	arr[ size ] = 'a';
	arr[ size + 1 ] = 'y';
	arr[ size + 2 ] = '\0';
	cout << arr << ' ';
}