[ create a new paste ] login | about

Link: http://codepad.org/z84oTMuL    [ raw code | output | fork ]

C++, pasted on Apr 7:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
int BinDec(char* bin)
{
    int rez = 0, i, size = strlen(bin);
    for(i = size - 1; i >= 0; --i)
        rez += ((int)bin[i] - 48)<<i;
    return rez;
}
int main()
{
    char ch[] = "1111";
    std::cout<<BinDec(ch);
}


Output:
1
15


Create a new paste based on this one


Comments: