I have a vector with [ '6' '0' '0' '0' '0'] from a user inputting 60,000. I need an int 60000 so I can manipulate this number.
I'm new to c++ and programming in general. I read data/numbers from 60,000-3,500,000 from a serial port and I need an integer number, the only way I have successfully done this and printed it is through std::vector. I tried to do vector but it gives me funky numbers.
#include "SerialPort.h"
std::vector<char> rxBuf(15);
DWORD dwRead;
while (1) {
dwRead = port.Read(rxBuf.data(), static_cast<DWORD>(rxBuf.size()));
// this reads from a serial port and takes in data
// rxBuf would hold a user inputted number in this case 60,000
if (dwRead != 0) {
for (unsigned i = 0; i < dwRead; ++i) {
cout << rxBuf[i];
// this prints out what rxBuf holds
}
// I need an int = 60,000 from my vector holding [ '6' '0' '0' '0 '0']
int test = rxBuf[0 - dwRead];
cout << test;
// I tried this but it gives me the decimal equivalent of the character
numbers
}
}
I need an output of 60000 not in a vector but rather as a solid number, any help would be appreciated thanks.