I’m creating a function void foo(int argc, char** argv)
in the same style as main from the command line. using a input from std::cin
.
ive experimented with a couple of ideas mainly using strtok and vectors, as well as a method involving reading directly from the input stream and reallocating a array. but can’t quite figure out the best method to achieve this without a vast amount of array reallocation or using vectors that seemed to have unnecessary overheads.
void foo(int argc, char** argv) {
//do somthing.
return;
}
int main() {
std::string tmp;
std::getline(std::cin, tmp)
//code here.
foo(var_count, vars);
}
many thanks.
edit: looking furthur into this the c style strtok feature is depreceated and has been replaced with new varients that appear to have platform compatability issues.