I'm trying to add two numbers given as command-line arguments in C, but without any use of functions except for printf.
(Cannot use functions like isDigit()
, atoi()
, scanf()
, etc.)
I think the ASCII Table would help, but I'm unsure how to include it.
Ex: The user gives as arguments: 3 + 5 Then three arguments are 3, +, and 5. The code should print 8.
Code so far:
int main(int argc, char*argv[])
{
char operator;
operator = argv[2][0];
char firstNum;
// check if firstNum is integer (max of 999 digits)
char secondNum;
// check if secondNum is integer (max of 999 digits)
int add;
add = firstNum + secondNum;
printf(sum);
}