char and int Convert
2006-12-17 17:13
225 查看
int atoi(
const char *str
);
int _wtoi(
const wchar_t *str
);
int _atoi_l(
const char *str,
_locale_t locale
);
int _wtoi_l(
const wchar_t *str,
_locale_t locale
);
Parameters
str String to be converted. locale Locale to use.Return Value
Each function returns the int value produced by interpreting the input characters as a number. The return value is 0 for atoi and _wtoi, if the input cannot be converted to a value of that type.
In Visual C++ 2005, in the case of overflow with large negative integral values, LONG_MIN is returned. atoi and _wtoi return INT_MAX and INT_MIN on these conditions. In all out-of-range cases, errno is set to ERANGE. If the parameter passed in is NULL, the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, these functions set errno to EINVAL and return 0.
errno_t _itoa_s(
int value,
char *buffer,
size_t sizeInCharacters,
int radix
);
errno_t _i64toa_s(
__int64 value,
char *buffer,
size_t sizeInCharacters,
int radix
);
errno_t _ui64toa_s(
unsigned _int64 value,
char *buffer,
size_t sizeInCharacters,
int radix
);
errno_t _itow_s(
int value,
wchar_t *buffer,
size_t sizeInCharacters,
int radix
);
errno_t _i64tow_s(
__int64 value,
wchar_t *buffer,
size_t sizeInCharacters,
int radix
);
errno_t _ui64tow_s(
unsigned __int64 value,
wchar_t *buffer,
size_t sizeInCharacters,
int radix
);
template <size_t size>
errno_t _itoa_s(
int value,
char (&buffer)[size],
int radix
); // C++ only
template <size_t size>
errno_t _itow_s(
int value,
wchar_t (&buffer)[size],
int radix
); // C++ only
Parameters
[in] value Number to be converted. [out] buffer Filled with the result of the conversion. [in] sizeInCharacters Size of the buffer in single-byte characters or wide characters. [in] radix Base of value; which must be in the range 2–36.Return Value
Zero if successful; an error code on failure. If any of the following conditions applies, the function invokes an invalid parameter handler, as described in Parameter Validation.
Security Issues
These functions can generate an access violation if buffer does not point to valid memory and is not NULL, or if the length of the buffer is not long enough to hold the result string.
相关文章推荐
- 整型转字符串(convert int to char)优化实践
- int to char* and char* to int
- atoi char and string to int
- GetWindowTextW(LPTSTR,int) const' :cannot convert parameter 1 from 'char[10]
- java int and string convert
- How can I convert a QString to char* and vice versa ?
- lua tips: convert between bytes and int
- 【C编程练习】2013华为校园招聘机试题9月10日题1:把整数转换成字符串 void ConvertIntToStr(int nVal, char* pStr);
- Determine the ranges of char , short , int , and long variables
- unsigned char * and AnsiString convert
- String convert int , and int convert String
- 整型转字符串(convert int to char)优化实践——一个意外的BUG
- int and char conversion
- java int and string convert
- error C2664: 'LONG CTabCtrl::InsertItem(int,TCITEMW *)' : cannot convert parameter 2 from 'char *' t
- error C2664: 'LONG CTabCtrl::InsertItem(int,TCITEMW *)' : cannot convert parameter 2 from 'char *' t
- python int convert string and vice versa
- How can I convert a QString to char* and vice versa?
- char* convert to string and back
- cannot convert from 'const int' to 'const char *'