hi all....
In c++ how to convert integer value to hexadecimal (in ANSI-C ).
wijitha...

Recommended Answers

All 6 Replies

what does that even mean?
integer is a type
hexadecimal is a representation of integers
it doesn't make any sense to "convert"

sorry it should be convert decimal number to hexadecimal.

One way to do it is by using standard C function printf()

int n = 123;
printf("%X", n);

so you have a string with a number in decimal, and you want to parse it into an integer, and then print it back out into a string in hexadecimal?

you can use atoi() to convert the string into an int, and then use sprintf() with %x for hex to print it back out

In developer c++ u can use hex keyword as shown cout<<hex<<number;

In c++ how to convert integer value to hexadecimal (in ANSI-C ).

Hey, this is a C++ forum. There is another forum for C.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.