Convert *argv[] (command line parameters) to unsigned char vector

  argv, c++, char, command-line, vector

In C++ I’m trying to convert command line *argv[] pointer (3 arguments) to vector of unsigned chars i.e. mytest 148 64 127

I got a vector:

vector<unsigned char> msg;

Vector includes 3 unsigned chars : msg = {0, 0, 0}
When I trying to convert in this way,

unsigned char c1 = *argv[1];
unsigned char c2 = *argv[2];
unsigned char c3 = *argv[3];
msg = {c1, c2, c3}

I get only first character of these chars.
i.e.
In command line I enter : mytest 148 64 127

I get : 1, 6 and 1

Source: Windows Questions C++

LEAVE A COMMENT