Get several values for the same option [duplicate]
问题 This question already has answers here : C getopt multiple value (5 answers) Closed 6 years ago . I have a program like this : ./server Which has this usage : Usage : -p Port to use (4242 by default) -x Map width (20) -y Map height (20) -n Team name (name_team1 name_team2) -c Players per team -t Delay I was able to parse all the options with this code : int parse_cmd(int argc, char **argv, t_args *a) { char ch; if (argv[1] && argv[1][0] != '-') usage(); while ((ch = getopt(argc, argv, "p:x:y