It appears that you won't be able to, however a fast hack should suffice:
static char * const ARGV[] = { "myprog", "hello", "world", NULL };
int main(int argc, char * argv[])
{
argc = 3;
argv = ARGV;
// ...
}
Alternatively, you may transform the standard input to args:
#include <vector>
#include <string>
#include <iterator>
#include <iostream>
std::vector<char *> fabricate(std::vector<std::string> & v)
{
std::vector<char *> res(v.size() + 1, NULL);
for (std::size_t i = 0; i != v.size(); ++i) { res[i] = &v[i][0]; }
return res;
}
std::vector<std::string> args_vector((std::istream_iterator<std::string>(std::cin)), std::istream_iterator<std::string>());
std::vector<char *> argv_vector = fabricate(args_vector);
int main(int argc, char * argv[])
{
argc = args_vector.size();
argv = argv_vector.data();
// ...
}