aboutsummaryrefslogtreecommitdiff
path: root/7.9.c
blob: 642efb1d480df8bc867d3058d552463f28651ff6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>

/* saves time (no function overhead) but uses more space
 * since the macro is expanded on each call, also
 * the argument can be evaluated twice and cause problems
 * eg: isupper_m(p++), the soln is isupper(p); p++ */
#define isupper_m(c) (c >= 'A' && c <= 'Z') ? 1 : 0

/* uses more time bus saves on space */
int isupper_f(char c);

int main(void)
{
	printf("M: %d, m: %d\n", isupper_m('M'), isupper_m('m'));
	printf("F: %d, f: %d\n", isupper_f('F'), isupper_f('f'));

	return 0;
}

int isupper_f(char c)
{
	return (c >= 'A' && c <= 'Z') ? 1 : 0;
}