Aren't you trying to reinvent the wheel? There are classes to do that. There is even a Qt based class available that performs such a task somewhere in the net. You might also look for getopt_long() implementation on Windows (it's a POSIX function, so it might be unavailable on your system). Or you could just iterate over argv and handle the options. I'd suggest the last solution...
int main(int argc, char**argv){
for(int i=1;i<argc;i++){
if(!strcmp(argv[i], "-o")){
fileToOpen = argv[++i];
continue;
}
/* ... */
}
return 0;
}
int main(int argc, char**argv){
for(int i=1;i<argc;i++){
if(!strcmp(argv[i], "-o")){
fileToOpen = argv[++i];
continue;
}
/* ... */
}
return 0;
}
To copy to clipboard, switch view to plain text mode
Bookmarks