I'm writing a command line calculator. Each expression is provided by user must be separated by space (that's convention). For example: ./calc 2 + 5 * sin 45
The problem is when I try to get each expression i get also as arguments all files that are in the folder that I've complied the code...
Here is the code:
int main(int argc, char* argv[]) {
double result;
int i;
printf("Number of arguments: %d\n", argc);
for (i=0; i<argc; i++) {
printf("Argument: %s\n", argv[i]);
}
//result = equation(argv, argc);
//printf("Result is: %f", result);
return 0;
}
And the output for that example expression is:
Number of arguments: 10
Argument: ./calc
Argument: 2
Argument: +
Argument: 5
Argument: calc
Argument: calculate.c
Argument: lab2
Argument: sin
Argument: 45
And my question is why there are calc calculate.c lab2 (of course the folder where this program is compiled contains all the three files). Should I compile it in separate folder? I tried that approach but still the 'calc' is there
ps. i'm using the gcc compiler: gcc calculate -o calc