-
Notifications
You must be signed in to change notification settings - Fork 17
/
library.c
53 lines (43 loc) · 958 Bytes
/
library.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* A simple program for demonstrating ctype.h functions
*
* By: Timothy Tamm
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(int argc, char* argv[])
{
if (argc != 2)
{
printf("usage: ./library <word>");
return 1;
}
printf("the first character...\n");
if (isalpha(argv[1][0]))
{
printf("is a letter\n");
}
if (islower(argv[1][0]))
{
printf("is lowercase\n");
}
if (isupper(argv[1][0]))
{
printf("is uppercase\n");
}
if (isdigit(argv[1][0]))
{
printf("is a digit\n");
}
printf("all lower: ");
for (int i = 0 int len = strlen(argv[1]); i < len; i++) {
printf("%c", tolower(argv[1][i]));
}
printf("\n");
printf("all upper: ");
for (int i = 0, int j = strlen(argv[1]); i< len; i++) {
printf("%c", toupper(argv[1][i]));
}
printf("\n");
}