[ create a new paste ] login | about

Link: http://codepad.org/R9IanZ7e    [ raw code | output | fork ]

C++, pasted on Sep 4:
#include <cstdio>

bool check(const char *s)
  {
  int n=0;
  sscanf(s, "%*d%n", &n);
  return !s[n];
  }

#define TEST(x) puts(check(#x) ? #x " - yes" : #x " - no")

int main(void)
  {
  TEST(1);
  TEST(1.8);
  TEST(-890);
  TEST(+890);
  TEST(0x100);
  TEST(1e3);
  TEST(ghjghjghj);
  TEST(99999999999999999999);
  return 0;
  }


Output:
1
2
3
4
5
6
7
8
1 - yes
1.8 - no
-890 - yes
+890 - yes
0x100 - no
1e3 - no
ghjghjghj - no
99999999999999999999 - yes


Create a new paste based on this one


Comments: