is there a way to fix this error (Unable to open file C:\xxxx\xxx\xx\Q1.obj. Error code = 0x80070002.)

-1

I fixed the code! thank you for your help the problem was that I didn't start the array's with the size of 4 but with 3 and I used strcmp to check if they are equal

#include <stdio.h>
#include <string.h>
#define SIZE 50
int main(int argc, char** argv)
{
    if (argc > 1) {
        int i, ans, result1, result2;
        int val[SIZE] = { 0 };
        char add_arr[4] = { 'A','D','D','\0' };
        char sub_arr[4] = { 'S','U','B','\0' };
        char* check_arr[4] = { argv[1] };
        for (i = 2; i < argc; i++)
        {
            val[i - 2] = atoi(argv[i]);
        }
        result1 = strcmp(*check_arr, add_arr);
        result2 = strcmp(*check_arr, sub_arr);
        if (argc > 3) {
            if (result1 == 0) {
                ans = add_mode(val);
                printf("Result: %d", ans);
            }
            else if (result2 == 0) {
                ans = sub_mode(val);
                printf("Result: %d", ans);
            }
            else {
                printf("ERROR! INVALID COMMAND!\nHow to use the program: <ADD / SUB> <number> ... <number>");
            }
        }
        else {
            printf("ERROR! INVALID NUMBER OF ARGUMENTS!\nHow to use the program: <ADD / SUB> <number> ... <number>");
        }
    }
    else {
        printf("ERROR!\nHow to use the program: <ADD / SUB> <number> ... <number>");
    }
    getchar();
    return 0;
}
c
asked on Stack Overflow May 4, 2021 by CallMeEdwin • edited May 4, 2021 by CallMeEdwin

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0