conversion int en sa valeur hexa

conversion int en sa valeur hexa - Programmation

Marsh Posté le 01-08-2001 à 19:46:20    

j'ai des int (c++) et j'aimerai avoir leur valeurs en hexa. Est ce que le C++ permet de le faire facilement?

Reply

Marsh Posté le 01-08-2001 à 19:46:20   

Reply

Marsh Posté le 01-08-2001 à 22:10:14    

Si tu veux parler de l'affichage en base 16, utilise cette fonction:
 
----------
#include <stdlib.h>
char *itoa(int value, char *string, int radix);
 
Description
 
Converts an integer to a string.
itoa converts value to a null-terminated string and stores the result in string. With itoa, value is an integer.
radix specifies the base to be used in converting value; it must be between 2 and 36, inclusive. If value is negative and radix is 10, the first character of string is the minus sign (-).
 
Note: The space allocated for string must be large enough to hold the returned string, including the terminating null character (\0). itoa can return up to 17 bytes.
 
Return Value
 
itoa returns a pointer to string.
 
Borland C++ 5.0 Programmer's Guide
----------
 
(oh, joli le copier-coller...)

Reply

Marsh Posté le 02-08-2001 à 07:50:05    

printf("valeur décimale : %d, valeur hexadécimale : %x,val,val);
 
%x pour l'avoir en minuscules
%X en majuscule.
 
vw


---------------
The best way to accelerate a computer running windows is at 9.8m.s-2
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed