|
@ -4,6 +4,7 @@ |
|
|
#include <stdlib.h> |
|
|
#include <stdlib.h> |
|
|
#include <string.h> |
|
|
#include <string.h> |
|
|
|
|
|
|
|
|
|
|
|
// checking integer input as operation id |
|
|
bool checkOperationInput(int input) { |
|
|
bool checkOperationInput(int input) { |
|
|
switch (input) { |
|
|
switch (input) { |
|
|
case 4: case 3: case 2: case 1: |
|
|
case 4: case 3: case 2: case 1: |
|
@ -12,9 +13,12 @@ bool checkOperationInput(int input) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// full input process |
|
|
int* evaluateInput(char* input, int operation) { |
|
|
int* evaluateInput(char* input, int operation) { |
|
|
|
|
|
// check if formatting is correct |
|
|
if(!containsTwoNumbers(input)) return NULL; |
|
|
if(!containsTwoNumbers(input)) return NULL; |
|
|
int firstNumber = extractFirstNumber(input); |
|
|
int firstNumber = extractFirstNumber(input); |
|
|
|
|
|
// origin string "input" has been edited |
|
|
int secondNumber = atoi(input); |
|
|
int secondNumber = atoi(input); |
|
|
int* result = malloc(sizeof(int)); |
|
|
int* result = malloc(sizeof(int)); |
|
|
switch (operation) { |
|
|
switch (operation) { |
|
|