blob: 612047786ecb6bdc3d8220b4105f4098cc035f01 (
plain)
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
|
#include <u.h>
#include <libc.h>
void
swap(char *a, char *b)
{
char tmp;
tmp = *a;
*a = *b;
*b = tmp;
}
void
rev(char *s, ulong len)
{
char *e;
e = s+len;
while(s < e)
swap(s++, --e);
}
void
usage(void)
{
fprint(2, "usage: %s text ...\n", argv0);
exits("usage");
}
void
main(int argc, char *argv[])
{
int first;
first = 1;
ARGBEGIN{
default: usage();
}ARGEND;
if(argc < 1)
usage();
while(argc--){
rev(argv[argc], strlen(argv[argc]));
print(first ? first--, "%s" : " %s", argv[argc]);
}
print("\n");
exits(nil);
}
|