Convert hex string (char []) to int?

前端 未结 13 937
栀梦
栀梦 2020-11-22 12:12

I have a char[] that contains a value such as \"0x1800785\" but the function I want to give the value to requires an int, how can I convert this to an int? I have searched a

相关标签:
13条回答
  • 2020-11-22 12:57

    Use xtoi ( stdlib.h ). The string has "0x" as first two indexes so trim val[0] and val[1] off by sending xtoi &val[2].

    xtoi( &val[2] );

    0 讨论(0)
提交回复
热议问题