fork(1) download
#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 &&
            pos == strlen(texts[i]))
        {
            printf("yes\n");
        }
        else
        {
            printf("no\n");
        }
    }
    return 0;
}
Success #stdin #stdout 0.01s 1720KB
stdin
Standard input is empty
stdout
Is foo=54 valid ? yes
Is foo=7h valid ? no
Is rubbish valid ? no