I decided today to re-write a simple calculator I wrote a while back in Java, to C. This time I'm trying to make the calculator a bit more advanced with a few command line options. Among many a -v option for verbose. When the -v option is set I want the output from the calculations (the -c option start the loop) to be written to a file. But there's a few problems. I'm using the getopt() function to retrieve the options set. If I use ./calc -vc (or -v -c) the verbose mode is on, and the calculation loop start. But if I do ./calc -cv (or -c -v), only the calculation loop starts. Why? The real problem here is I don't know how to write the input/output from the loop to a file. Should I create a buffer? How do I tell (check) the loop that the -v option is set?
Here's some of the code (I have cut most of it off, if more is needed let me know):
Code:
    while((argument = getopt(argc, argv, "hvcV")) != -1) {

        switch(argument) {

            case 'h':
                help();
                break;

            case 'v':
                printf("verbose mode on\n");
                verbose();
                break;

            case 'c':
                printf("options:\t+ - / *\n");
                calculate();
                break;
A part of the calculate(), which loops until either Q or q is pressed:
Code:
        switch(option) {

            case '+':
            case '1':
                printf("first value:\t");
                first = userInput();
                printf("second value:\t");
                second = userInput();
                total = first + second;
                printf("total:\t\t%.3f\n", total);
                break;
Any suggestions? Thanks in advance.