开发者

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

开发者 https://www.devze.com 2023-01-12 12:03 出处:网络
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:

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

精彩评论

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