This is a simple calcualtor program. What I don't understand is how I could modify it so that the calculation parameters could be intered from cmd. I don't understand how the argv and argc really work in this case. Do I need to replace all the ints with argv or something?
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[]){
int num1, num2, result;
char op;
int check=0;
do{
printf("Enter a calculation or press q to quit: ");
scanf("%d%c%d", &num1, &op, &num2);
if (op=='q'){
check = 1;
return 0;
}
else{
if (op =='+')
{result = num1+num2;
printf("%d\n", result);}
else if
(op =='-') {result = num1-num2;
printf("%d\n", result);
}
else if
(op =='*') {result = num1*num2;
printf("%d\n", result);
}
else if
(op =='/') {result = num1/num2;
printf("%d\n", result);
}
}
}while(!check);
return 0;
}