开发者

How can i get the numerical value (convert it to int) from a string?

I only see strings with only numbers. this is my string. SMUL 9 A B How can I get the number 9 as 开发者_如何学Cint type. Other possible string may be: SMUL 13 A B SMUL 43 100 21


try your luck with atoi


You can use the atoi library function:

   int atoi(const char *nptr);


atoi is bad, there is no error-handling, eg: atoi("0")==atoi("foobar") ! use strtol or sscanf instead.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜