开发者

"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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜