c - Use sscanf for regex purpose -


i have string str, if str composed of pure digits, extract digits int, if not, extract nothing or 0.

for example,

str = "12345";  // composed of pure digits, extract 12345 str = "123abc";  // not pure digits, extract nothing or 0 

can using sscanf? how?

int  value; char unused; if (1 == sscanf(mystring, "%d%c", &value, &unused)) {     // success } else {     // bad input } 

Comments

Popular posts from this blog

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

javascript - return highlighted cells to php -

java - Creating a room by reading from a file (for a game) -