all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
36
Task/String-case/C/string-case.c
Normal file
36
Task/String-case/C/string-case.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* Demonstrate toupper and tolower for
|
||||
standard C strings.
|
||||
This does not work for multibyte character sets. */
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* upper-cases s in place */
|
||||
void str_toupper(char *s)
|
||||
{
|
||||
while(*s)
|
||||
{
|
||||
*s=toupper(*s);
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* lower-cases s in place */
|
||||
void str_tolower(char *s)
|
||||
{
|
||||
while(*s)
|
||||
{
|
||||
*s=tolower(*s);
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char t[255]="alphaBETA";
|
||||
str_toupper(t);
|
||||
printf("uppercase: %s\n", t);
|
||||
str_tolower(t);
|
||||
printf("lowercase: %s\n", t);
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue