Change string case using its pointer
#include <ctype.h>
#include <stdio.h>
int main(void)
{
char str[80], *p;
printf("Enter a string: ");
gets(str);
p = str;
while( *p ) {
*p = toupper(*p);
p++;
}
printf("%s\n", str); /* uppercase string */
p = str; /* reset p */
while( *p ) {
*p = tolower(*p);
p++;
}
printf("%s\n", str); /* lowercase string */
return 0;
}
Related examples in the same category