三項演算子を使って、tolowerを書けという問題。
#include <stdio.h>
#include <assert.h>
static int my_lower(int c);
static void test_my_lower(void);
int
main(void)
{
test_my_lower();
}
static void
test_my_lower()
{
assert(my_lower('0') == '0');
assert(my_lower('a') == 'a');
assert(my_lower('z') == 'z');
assert(my_lower('A') == 'a');
assert(my_lower('Z') == 'z');
}
static int
my_lower (int c)
{
return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c;
}