简体   繁体   中英

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 AB How can I get the number 9 as int type. Other possible string may be: SMUL 13 AB SMUL 43 100 21

尝试atoi的运气

您可以使用atoi库函数:

   int atoi(const char *nptr);

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM