#include <stdio.h>
#include <stdlib.h>
int main(void) {
char * ptr;
long parsed = strtol("11110111", & ptr, 2);
printf("%lX\n", parsed);
return EXIT_SUCCESS;
}
For larger numbers, there as a long long
version, strtoll
.
More Related Contents:
- How do you convert decimal in integer to hexadecimal in integer? [closed]
- Write a c++ function that will prompt a user for an integer and convert it to binary and print in reverse order [duplicate]
- Explanation of shift operationals use in condition
- Leading zeros of a binary number doesn’t get printed
- Can I use a binary literal in C or C++?
- Reading and writing binary file
- How to print (using cout) a number in binary form?
- Is it safe to use -1 to set all bits to true?
- Read binary data from std::cin
- Why unsigned int 0xFFFFFFFF is equal to int -1?
- How to reverse an std::string? [duplicate]
- Why does -INT_MIN = INT_MIN in a signed, two’s complement representation?
- C++ – Decimal to binary converting
- How to do serialization of Class having members of custom data types in C++? [closed]
- Efficient bitwise operations for counting bits or find the right|left most ones
- Fastest way to Convert String to Binary?
- Difference between opening a file in binary vs text [duplicate]
- Why Doesn’t reinterpret_cast Force copy_n for Casts between Same-Sized Types?
- How to allocate memory dynamically for class using new in C++?
- Why do I get “unresolved external symbol” errors when using templates? [duplicate]
- What does it mean to “ODR-use” something?
- Why use std::bind over lambdas in C++14?
- ‘colon’ and ‘auto’ in for loop c++? need some help understanding the syntax
- Difference Between *(Pointer + Index) and Pointer[]
- Why does gcc compiler output pow(10,2) as 99 not 100? [duplicate]
- Most optimized way of concatenation in strings
- Why does `int ;` compile fine in C, but not in C++?
- Is there a clean way to prevent windows.h from creating a near & far macro?
- If a 32-bit integer overflows, can we use a 40-bit structure instead of a 64-bit long one?
- Wrapping FILE* with custom std::ostream