fork(28) download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void test(char *str) {
  5. int len;
  6. float ignore;
  7. int ret = sscanf(str, "%f %n", &ignore, &len);
  8. printf("'%s'\t\t: %d\n", str, ret && len==strlen(str));
  9. }
  10.  
  11. int main(void) {
  12. test("5.5");
  13. test("5.5 ");
  14. test(" 5.5 ");
  15. test("hello");
  16. test("123.ok");
  17. test("");
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 10320KB
stdin
Standard input is empty
stdout
'5.5'		: 1
'5.5 '		: 1
' 5.5 '		: 1
'hello'		: 0
'123.ok'		: 0
''		: 0