C getopt multiple value
问题 My argument is like this ./a.out -i file1 file2 file3 How can I utilize getopt() to get 3 (or more) input files? I\'m doing something like this: while ((opt = getopt(argc, argv, \"i:xyz..\"))!= -1){ case \'i\': input = optarg; break; ... } I get just the file1 ; how to get file2 , file3 ? 回答1: If you must, you could start at argv[optind] and increment optind yourself. However, I would recommend against this since I consider that syntax to be poor form. (How would you know when you've reached