"hello x" - string compare
I need to see if my string
matches "hello X" where X is any i开发者_开发问答nt
.
Basically I want to catch if its "hello 1" or "hello 100".
How best can I do it?
Edit 0
Thanks Andrea Bergia.
I am using your code like this:
int dummy;
if (sscanf(string, "hello %d", &dummy))
/* matched */
int dummy;
int n = sscanf(string, "hello %d", &dummy);
if (n == 1) {
// Matched
}
Several ways to go about it. First thought is to use a regular expression, but that may be over kill for your requirements.
http://www.gnu.org/s/hello/manual/libc/Pattern-Matching.html
精彩评论