Is there a good example of how toupper() works?

Jack Morrison jackm at agcsun.UUCP
Fri Oct 19 00:35:16 AEST 1990


>>	char *duh = "Hello";
>>	printf("%s\n", duh);
>>	while (*duh <= strlen(duh)) {
>>		if (islower(*duh)) *duh = toupper(*duh);
>>		*duh++;
>>	}
>
>(An aside: since strlen(duh) never changes, either you or the compiler
>should move it outside the loop.) 
>							Bill

Even better, just use

	while (*duh) {
		if (islower(*duh)) *duh = toupper(*duh);
		duh++;
	}

(or for anal types, :-)
	while (*duh != '\0') {

-- 
"How am I typing?  Call 1-303-279-1300"     Jack C. Morrison
Ampex Video Systems    581 Conference Place, Golden CO 80401



More information about the Comp.lang.c mailing list