convert char* array to string array
Im trying to convert the command line arguments to string form instead of char*, but it obviously isnt working since Im asking this question :rolleyes:
Heres the code:
Code:
string* charstararray2stringarray(int args, char* argv[]);
int main(int args, char* argv[])
{
string* stringarray;
stringarray = charstararray2stringarray(args,argv);
retrun 0;
}
string* charstararray2stringarray(int args, char* argv[])
{
//converts char*[] to string[]
//used for command line
string* retVal;
retVal = new string[args];
for (unsigned int i = 0; i <= args; i++)
{
retVal[i] = (string)argv[i];
}
return *retVal;
delete [] retVal;
}