#include <iostream.h> #include <ctype.h> void convertToUppercase( char * ); int main() { char string[] = "characters and $32.98"; cout << "The string before conversion is: " << string; convertToUppercase( string ); cout << "\nThe string after conversion is: " << string << endl; return 0; } void convertToUppercase( char *sPtr ) { while ( *sPtr != '\0' ) { if ( *sPtr >= 'a' && *sPtr <= 'z' ) *sPtr = toupper( *sPtr ); // convert to uppercase ++sPtr; // move sPtr to the next character } }
OUTPUT: The string before conversion is: characters and $32.98 The string after conversion is: CHARACTERS AND $32.98
No comments:
Post a Comment