D
D
Dmitry Korolev2018-06-17 06:15:51
C++ / C#
Dmitry Korolev, 2018-06-17 06:15:51

How to convert string with hexadecimal number to decimal system?

I have a string with a hexadecimal value, how do I represent it in decimal format?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Derevianko Alexander, 2018-06-17
@dio4

here
is the code for you in pure "si"

#include <stdio.h>
#include <stdlib.h>
int main ()
{
   char numbers[] = "0x6fffff"; // ваша исходная строка
   long int li4 = strtol(numbers, NULL, 0); // получите ваш эквивалент
   printf("Десятичный эквивалент распознанного числа:%ld\n", li4); 
   char buff[100];
   sprintf( buff, "%ld", li4 ); // если нужно эквивалент снова сделать строкой
   printf("Ваша строка из числа: %s\n", buff);
   return EXIT_SUCCESS;
}
/* консоль
Linux ubuntu14 3.13.0-153-generic #203-Ubuntu SMP Thu Jun 14 08:52:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[email protected]:~/tmp$ gcc trans.c -o trans_c
[email protected]:~/tmp$ ./trans_c
Десятичный эквивалент распознанного числа:7340031
Ваша строка из числа: 7340031
*/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question