Advertisement
irmantas_radavicius

Untitled

Oct 18th, 2021
853
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(){
  5.    
  6.     char str1[256] = { 0 };
  7.     char str2[256] = { 0 };
  8.     int x, y;
  9.     char c = 0;
  10.     fscanf(stdin, "%255s", str1);
  11.     if ((sscanf(str1, "(%d%c", &x, &c) == 2) && (c == ')')){
  12.         printf("It is a number\n");
  13.     } else if ((sscanf(str1, "[%d%c", &x, &c) == 2) && (c == ']')){
  14.         printf("It is a number\n");
  15.     } else {
  16.         printf("It is NOT a number\n");
  17.     }
  18.  
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement