I'm not sure if this is the only problem but you're setting of choice_f and choice_m is incorrect and should be
scanf("%c", &choice_f);
scanf("%c", &choice_m);
instead. i.e. You should use the %c
format specifier instead. If you use %s
, a nul terminator (at the very least) will be written; you haven't provided storage for this so other stack variables will be over-written.
After that, as suggested by Nicholas Wilson, you should change flags
to be int
rather than char*
(and remove the quotes from the assignments to O_RDONLY etc.)