-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathgetopt.cpp
More file actions
42 lines (36 loc) · 756 Bytes
/
getopt.cpp
File metadata and controls
42 lines (36 loc) · 756 Bytes
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
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <getopt.h>
using namespace std;
int main (int argc, char* argv[]) {
if ( argc < 3 ) {
cerr << "Please add some options\n";
return 1;
}
int replace = 0;
for (;;) {
switch(getopt(argc, argv, "r")) {
default:
cerr << " fount " << optarg << "\n";
case -1:
cerr << "Found -1\n";
break;
case 'r':
cout << "Flag r set";
replace = 1;
continue;
}
break;
}
cerr << "argc: " << argc << "\n";
cerr << "Optind: " << optind << "\n";
if (optind +2 != argc) {
cerr << " <fastq file> <fasta file>";
return 1;
}
char* fqf = argv[optind];
char* faf = argv[optind+1];
cout << "Fastq: " << fqf << " Fasta: " << faf << "\n";
}