Can anybody give me a snippet to change a sentence from lowercase to uppercase? All letters should be in uppercase.

Here a function to do what you need

#include /* Macros of characters classification /
#include /
Only included for the NULL */

/*

  • str2upr:
  • Converts each lower case character of null terminated string
  • to upper case. Rewrites input string.
  • Returns pointer to input string
  • If pointer to input string is NULL, returns NULL
    */

char *
str2upr( char *p )
{
char *q;

if( p == NULL ) /* Defensive programming /
return NULL; /
You can take them away if you are
completly sure of argument */

for( q = p ; *p != ‘0’ ++p )
*p = toupper( *p );
return q;
}

Macro “toupper” only converts those characters thar are alphabetic and lower
case
so you don’t need to verify previously that all characters in string are
alphabetic and lower case

Regards

Eduardo

#include

If you don’t like toupper you can always subtract 32 from the chr value in
c.

ASCII ‘a’ - ASCII ‘A’ = 32! so ASCII ‘a’ - 32 = ‘A’!

Of course toupper is a better choice as it does range ckecking, etc…

Regards,

See the documentation.
toupper(c) is really a macro that receives an ascii code in c and returns an
upper case letter in case c was a lower case one. You must include

there is library function in c i.e toupper()

it changes all the lower latters into capital

latter

Use toupper() (see manpage)
Something like this:

#include