The array options
contains elements of this form: "-option=value".
The argument needed_option
contains for example "option"
char *function(char *options[], char *needed_option){
for(//go over all possible options){
if(fnmatch("-???=*", options[i], 0) == 0){ //<--- look here
char *ret = extract_value_from_option();
return ret;
}
}
}
Question: Is there a way to genericly replace the " ???
" with the function - argument needed_option
like its done in printf()
where a char *
can be included by using the %s
?
prepare it with sprintf()
char current[256];
sprintf(current, "-%s=*", needed_option);
//...
if(fnmatch(current, options[i], 0) == 0){ //...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.