hello guys i have a favour to ask i would like to help me out with this problem ..

4) Write a method binaryToDecimal that takes a string as argument (the string consists of a sequence of ’0’ and ‘1’ characters representing the binary representation of a number) and returns an integer with the decimal value of the number. The decimal value of a number with the binary representation of the form may be computed as . Use the method above to write a program that takes a command line argument N followed by N strings representing binary number representations and prints their decimal values.

This converts a string named input (which should be all ones and zeros) to a decimal integer. Remember to set your compiler to C++11 or later. std::stoi lives in <string>

int x = std::stoi(input, nullptr, 2);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.