-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.c
33 lines (30 loc) · 822 Bytes
/
main.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
#include <stdio.h>
#include "version.h"
int usage(int code)
{
printf("Hello world example %s\n"
"Copyright Jiang Xin <jiangxin AT ossxp DOT com>, 2009.\n"
"\n"
"Usage:\n"
" hello\n"
" say hello to the world.\n\n"
" hello <username>\n"
" say hi to the user.\n\n"
" hello -h, -help\n"
" this help screen.\n\n", _VERSION);
return code;
}
int
main(int argc, char **argv)
{
if (argc == 1) {
printf ("Hello world.\n");
} else if ( strcmp(argv[1],"-h") == 0 ||
strcmp(argv[1],"--help") == 0 ) {
return usage(0);
} else {
printf ("Hi, %s.\n", argv[1]);
}
printf( "(version: %s)\n", _VERSION );
return 0;
}