-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.c
More file actions
55 lines (41 loc) · 1.17 KB
/
Copy pathtest.c
File metadata and controls
55 lines (41 loc) · 1.17 KB
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
54
55
//SPDX-License-Identifier: GPL-3.0
/*--This is a test file And you can refer to this as example ---
* This file answer the Question how to use it ??
* Copyright(c) 2026 , Umar Ba <jUmarB@protonmail.com>
*/
#include <stdio.h>
#include "optkit.h"
extern char * optkit_help;
optkit_begin(options, "This program is a test\n\
just a illustration programm")
noarg("help" , "show this help" , 'h') ,
rearg("output" ,"redirect output", 'O') ,
oparg("input" , "redirect input") ,
optkit_ends("The end footer should content the copyright\n\
,author and the version of the program")
void argument_handler(int * option , void * your_extra_data)
{
if(your_extra_data)
{
puts("has something inside") ;
}
switch(*option)
{
case 'O':
puts("the big O notation") ;
break ;
case 'i':
printf("Input data %s \n" , optarg) ;
break;
default:
printf("%s" , optkit_help) ;
break ;
}
}
int main(int ac , char * const *av)
{
int your_extra_data= 10 ;
if(optkit_parse(av , options , argument_handler, (void *) &your_extra_data))
fprintf(stderr , "%s" , optkit_help) ;
return 0 ;
}