✔ 最佳答案
You can actually do this check very fast as long as you don't care if it is a number with a decimal point (not an integer, but still a positive number):
char * your_string = (something);
if (isdigit(*your_string)) {
return true;
} else {
return false;
}
This only finds strings that actually start with a number -- if you had something like " 15" it would not work and you would have to advance the pointer past the whitespace first. Still, that gives you the basic idea.
isdigit is in the ctype library -- you will need to type #include <ctype.h> at the top of your code.