You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
837 B

11 months ago
11 months ago
11 months ago
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "operationHandler.h"
  4. char buffer[100];
  5. int main() {
  6. printf("Please enter the id of a specific operation...\n1. addition\n2. subtraction\n3. multiplication\n4. division\n");
  7. int input;
  8. scanf("%d", &input);
  9. if(!checkOperationInput(input)) {
  10. printf("Invalid operation id\n");
  11. return 0;
  12. }
  13. printf("\nPlease enter the first and the second number separated by a space...\n");
  14. while(fgets(buffer, 100, stdin)) {
  15. buffer[strcspn(buffer, "\n")] = '\0';
  16. if (strlen(buffer) > 0) {
  17. break;
  18. }
  19. }
  20. int* result = evaluateInput(buffer, input);
  21. if(result == NULL) {
  22. printf("\nInvalid formatting. Two numbers need to be separated by a space\n");
  23. return 0;
  24. }
  25. printf("\nResult: %d", *result);
  26. }