#include <stdio.h> #include <stdlib.h> int main(void) { const char *text = "42rest"; char *end; long n = strtol(text, &end, 10); printf("%ld, stopped at '%s'\n", n, end); return 0; }
strtol reports where it stopped