Converts a lowercase character to uppercase.
int toupper ( int c );
This function has the following parameter.
The uppercase equivalent to c, if such value exists, or c (unchanged) otherwise.
The value is returned as an int value that can be implicitly casted to char.
#include <stdio.h>
#include <ctype.h>
//from w w w. jav a 2s .c om
int main (){
int i=0;
char str[]="Test String.\n";
char c;
while (str[i])
{
c=str[i];
putchar (toupper(c));
i++;
}
return 0;
}
The code above generates the following result.
#include <stdio.h>
#include <ctype.h>
#include <locale.h>
#include <limits.h>
/*from w w w .j a v a 2 s .c o m*/
int main(void)
{
unsigned char u;
for (unsigned char l=0; l<UCHAR_MAX; l++) {
u = toupper(l);
if (l!=u) printf("%c%c ", l,u);
}
printf("\n\n");
unsigned char c = '\xb8'; // the character ? in ISO-8859-15
// but ? (acute accent) in ISO-8859-1
unsigned char c2 = c; // for printing
setlocale(LC_ALL, "en_US.iso88591");
printf("in iso8859-1, toupper('0x%x') gives 0x%x\n", c2, toupper(c));
setlocale(LC_ALL, "en_US.iso885915");
printf("in iso8859-15, toupper('0x%x') gives 0x%x\n", c2, toupper(c));
}
The code above generates the following result.