Advertisement
sp1d3o

Untitled

Oct 2nd, 2021
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<ctype.h>
  4. #include<stdbool.h>
  5.  
  6. bool check_input(char *a)
  7. {
  8.  
  9. int i, len;
  10.  
  11. len = strlen(a);
  12.  
  13. bool x;
  14.  
  15. for(i = 0; i < len; i++) {
  16.     if(isdigit(a[i]) || isspace(a[i])) {
  17.         bool x = true;
  18.     }
  19.     else if(a[i] == '+' || '-' || '*' || '/') {
  20.     }
  21.     else{
  22.         return false;
  23.     }
  24. }
  25. return true;
  26. }
  27.  
  28. int main()
  29. {
  30. char b[500];
  31.  
  32. scanf("%s", b);
  33.  
  34. if(!check_input(b)) {
  35.     printf("Invalid character in input\n");
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement