I am trying to compare options that can be entered on the command line for my program. for option f a user can enter c or b.
int main(int argc, char** argv){
char *i;
char *o;
char *f;
int c;
while ((c = getopt (argc, argv, "i:o:f")) != -1)
switch (c)
{
case 'i':
i = optarg;
break;
case 'o':
o = optarg;
break;
case 'f':
f = optarg;
break;
}
if(strcmp(f, "b") == 0){
//execute code
}
}
When I run this I get the following error:
Program received signal SIGSEGV, Segmentation fault.
__strcmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:115
115 ../sysdeps/x86_64/multiarch/strcmp-avx2.S: No such file or directory.
Edit: I'm using Linux and running
gcc -g program.c program
gdb --args ./program -f b