LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

decimal to hexadecimal

Solved!
Go to solution

How can i convert an integer to hexadecimal string in CVI ?

CVI 2017

thanks

0 Kudos
Message 1 of 6
(4,322 Views)

Using "%x" format code in sprintf. This is not CVI, it's pure C



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 6
(4,305 Views)

j'ai  utilisé  Fmt (hex, "%x<%i",dec) mais ça ne marche pas

0 Kudos
Message 3 of 6
(4,290 Views)
Solution
Accepted by chayma

Since in this case Fmt expects an integer in output, the correct format should be

Fmt (&hex, "%x<%i", dec);

But this is really useless: there will be no difference in memory between dec and hex! As you surely know, hexadecimal, decimal, octal, binary... are only representations of the very same thing.

 

You correctly stated in your original question that you wanted a "hexadecimal string", so the correct call should be

char	string[16];

Fmt (string, "%s<0x%x", dec);

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 6
(4,285 Views)

Merci pour la réponse

Ça marche bien 

Est-ce vous pouvez m'indiquer l'instruction qui convertir de hexadécimal au décimal 

Et merci d'avance

0 Kudos
Message 5 of 6
(4,278 Views)
Solution
Accepted by chayma

That is, extract the number from an hexadecimal string?

sscanf (string, "%x", &dec);


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 6
(4,274 Views)