online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ #include <stdio.h> #include <string.h> #include <math.h> unsigned long long int bin2dec(const char *string, const size_t size) { unsigned long long int value = 0; for(size_t index=0;index<size;index++) { // moving from the end to the beginning, get a character from the string // and convert it from a character containing a digit to a number short bit = string[size-index-1]-'0'; // in the original question this was: value += bit*pow(2,index); // but we can just do this and get the same effect // without multiplication or library function value += bit<<index; } return value; } int main() { const char * binary = "111111111111111111111111111111"; unsigned long long int decimal = bin2dec(binary, strlen(binary)); printf("%llu\n",decimal); return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue