Your example is incomplete since you are not saying the exact type of vector. I assume this is std :: vector <char> (which perhaps you filled each char from line C).
My solution would be to convert it again to char *, which would give the following code:
void doSomething(const std::vector & token)
{
char c[2] = {token.at(0), 0} ;
int pid = std::atoi(c) ;
}
Please note that this is a C-shaped solution (i.e. rather ugly in C ++ code), but it remains effective.
source
share