- Joined
- Feb 11, 2008
- Messages
- 607 (0.10/day)
- Location
- Omaha, Nebraska, USA
System Name | Built By Me |
---|---|
Processor | Intel Core i9 9900K @ 5.1 GHz |
Motherboard | Gigabyte Z390 Aorus Ultra |
Cooling | Custom Water Cooling - CPU Only |
Memory | 32GB (2 x 16) GSkill Ripjaws V DDR4 |
Video Card(s) | RTX 4080 - ASUS ROG Strix 16GB OC - P Mode |
Storage | 1TB Samsung 970 Evo NVMe |
Display(s) | Alienware AW2723DF @ 280 Hz @ 1440P |
Case | Fractal Design Define S2 |
Audio Device(s) | Corsair Virtuoso Pro |
Power Supply | 850W Seasonic Platinum |
Mouse | Razer Viper V2 Pro @ 2k Hz |
Keyboard | Asus ROG Strix Scope II 96 Wireless - ROG NX Snow Switches |
Software | Windows 11 Pro |
I am trying to write a program to convert binary to decimal. I was thinking that maybe I could read all of the 0's and 1's together as a string, and then convert them to integers during the actual binary to decimal conversion. I keep on getting this error:
: error C2664: 'atoi' : cannot convert parameter 1 from 'char' to 'const char *'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Code:
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main()
{
string bin;
cout << "Give binary code: ";
cin >> bin;
for(int i = 0; i < bin.size(); i++)
{
cout << atoi(bin[i]) * 2;
}
return 0;
}