#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int main()
{
const char* texts[] = { "foo=54", "foo=7h", "rubbish", NULL };
int pos, foo, i;
for (i = 0; texts[i]; i++)
{
printf("Is %s valid ? ", texts
[i
]); if (sscanf(texts
[i
], "foo=%d%n", &foo
, &pos
) == 1 && {
}
else
{
}
}
return 0;
}
I2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8c3RyaW5nLmg+CiNpbmNsdWRlIDxzdGRpby5oPgoKaW50IG1haW4oKQp7CiAgICBjb25zdCBjaGFyKiB0ZXh0c1tdID0geyAiZm9vPTU0IiwgImZvbz03aCIsICJydWJiaXNoIiwgTlVMTCB9OwogICAgaW50IHBvcywgZm9vLCBpOwogICAgZm9yIChpID0gMDsgdGV4dHNbaV07IGkrKykKICAgIHsKICAgICAgICBwcmludGYoIklzICVzIHZhbGlkID8gIiwgdGV4dHNbaV0pOwogICAgICAgIGlmIChzc2NhbmYodGV4dHNbaV0sICJmb289JWQlbiIsICZmb28sICZwb3MpID09IDEgJiYKICAgICAgICAgICAgcG9zID09IHN0cmxlbih0ZXh0c1tpXSkpCiAgICAgICAgewogICAgICAgICAgICBwcmludGYoInllc1xuIik7CiAgICAgICAgfQogICAgICAgIGVsc2UKICAgICAgICB7CiAgICAgICAgICAgIHByaW50Zigibm9cbiIpOwogICAgICAgIH0KICAgIH0KICAgIHJldHVybiAwOwp9Cg==