My question is how I would go about converting something like:
int i = 0x11111111;
to a character pointer? I tried using the itoa() function but it gave me a floating-point exception.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
itoais non-standard. Stay away.One possibility is to use
sprintfand the proper format specifier for hexa i.e.xand do:However, the problem with this computing the size of the
valuearray. You have to do with some guesses and FAQ 12.21 is a good starting point.The number of characters required to represent a number in any base
bcan be approximated by the following formula:Add a couple more to hold the
0x, if need be, and then yourBIG_ENOUGHis ready.